Sujet : D correctly simulated by H cannot possibly reach its own line 06
De : polcott333 (at) *nospam* gmail.com (olcott)
Groupes : comp.lang.cDate : 18. May 2024, 20:10:45
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <v2aufl$2tsp6$1@dont-email.me>
References : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
User-Agent : Mozilla Thunderbird
On 5/18/2024 2:03 PM, Keith Thompson wrote:
James Kuyper <jameskuyper@alumni.caltech.edu> writes:
[...]
"Undefined behavior" is a piece of C jargon. You cannot understand the
meaning of the term by treating it as an ordinary English phrase:
"behavior which has no definition'.
[...]
This is important, because strictly conforming code cannot
have undefined behavior. If the C standard has no definition for the
behavior of some code, it cannot be strictly conforming, even if some
other document does define the behavior.
[...]
It's also important to note that "strictly conforming" is a piece of C
jargon. I don't know (or care) whether strict conformance is relevant
to the discussion that should have stayed in comp.theory.
If something in comp.theory raises a question about C, I suggest
starting a new thread in comp.lang.c rather than cross-posting.
Followups redirected back to comp.theory.
People are saying that they have no idea what this code does
because they do not believe it conforms to c11 or c17.
typedef int (*ptr)(); // ptr is pointer to int function
00 int H(ptr x, ptr y);
01 int D(ptr x)
02 {
03 int Halt_Status = H(x, x);
04 if (Halt_Status)
05 HERE: goto HERE;
06 return Halt_Status;
07 }
08
09 int main()
10 {
11 H(D,D);
12 return 0;
13 }
In the above case a simulator is an x86 emulator that correctly emulates
at least one of the x86 instructions of D in the order specified by the
x86 instructions of D.
This may include correctly emulating the x86 instructions of H in the
order specified by the x86 instructions of H thus calling H(D,D) in
recursive simulation.
*Execution Trace*
Line 11: main() invokes H(D,D);
*keeps repeating* (unless aborted)
Line 01:
Line 02:
Line 03: simulated D(D) invokes simulated H(D,D) that simulates D(D)
*Simulation invariant*
D correctly simulated by H cannot possibly reach past its own line 03.
The key thing to note is that no D correctly simulated by any H of every
H/D pair specified by the above template ever reaches its own line 06
and halts.
-- Copyright 2024 Olcott "Talent hits a target no one else can hit; Geniushits a target no one else can see." Arthur Schopenhauer