Path: ...!weretis.net!feeder8.news.weretis.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: wij Newsgroups: comp.lang.c++ Subject: Re: Can someone please verify the execution trace of this? Date: Tue, 21 May 2024 02:23:23 +0800 Organization: A noiseless patient Spider Lines: 201 Message-ID: <239b5d6057b5b9d7b63d62235fac97facb039718.camel@gmail.com> References: <32565d46f03edef2380267eeb552fcce102e6753.camel@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Injection-Date: Mon, 20 May 2024 20:23:24 +0200 (CEST) Injection-Info: dont-email.me; posting-host="ef40af8de3ec9bd1fc1347cc87190775"; logging-data="140323"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/i5fdDHlQWjHjsArZZMsoA" User-Agent: Evolution 3.50.2 (3.50.2-1.fc39) Cancel-Lock: sha1:0EGw62utqArasxwlxV/QMUhqh74= In-Reply-To: Bytes: 8969 On Mon, 2024-05-20 at 12:23 -0500, olcott wrote: > On 5/20/2024 11:21 AM, wij wrote: > > On Mon, 2024-05-20 at 10:02 -0500, olcott wrote: > > > On 5/20/2024 7:37 AM, wij wrote: > > > > On Sun, 2024-05-19 at 21:43 -0500, olcott wrote: > > > > > On 5/19/2024 8:52 PM, Bonita Montero wrote: > > > > > > Am 19.05.2024 um 21:00 schrieb olcott: > > > > > > > On 5/19/2024 1:08 PM, Bonita Montero wrote: > > > > > > > > Am 18.05.2024 um 23:40 schrieb olcott: > > > > > > > > > People are saying that they have no idea what this code d= oes > > > > > > > > > because they do not believe it conforms to c11 or c17. > > > > > > > > >=20 > > > > > > > > > typedef int (*ptr)();=C2=A0 // ptr is pointer to int func= tion > > > > > > > > > 00 int H(ptr x, ptr y); > > > > > > > > > 01 int D(ptr x) > > > > > > > > > 02 { > > > > > > > > > 03=C2=A0=C2=A0 int Halt_Status =3D H(x, x); > > > > > > > > > 04=C2=A0=C2=A0 if (Halt_Status) > > > > > > > > > 05=C2=A0=C2=A0=C2=A0=C2=A0 HERE: goto HERE; > > > > > > > > > 06=C2=A0=C2=A0 return Halt_Status; > > > > > > > > > 07 } > > > > > > > > > 08 > > > > > > > > > 09 int main() > > > > > > > > > 10 { > > > > > > > > > 11=C2=A0=C2=A0 H(D,D); > > > > > > > > > 12=C2=A0=C2=A0 return 0; > > > > > > > > > 13 } > > > > > > > > >=20 > > > > > > > > > In the above case a simulator is an x86 emulator that cor= rectly > > > > > > > > > emulates > > > > > > > > > at least one of the x86 instructions of D in the order sp= ecified by the > > > > > > > > > x86 instructions of D. > > > > > > > > >=20 > > > > > > > > > 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. > > > > > > > > >=20 > > > > > > > > > *Execution Trace* > > > > > > > > > Line 11: main() invokes H(D,D); > > > > > > > > >=20 > > > > > > > > > *keeps repeating* (unless aborted) > > > > > > > > > Line 01: > > > > > > > > > Line 02: > > > > > > > > > Line 03: simulated D(D) invokes simulated H(D,D) that sim= ulates D(D) > > > > > > > > >=20 > > > > > > > > > *Simulation invariant* > > > > > > > > > D correctly simulated by H cannot possibly reach past its= own line 03. > > > > > > > > >=20 > > > > > > > > > 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. > > > > > > > > >=20 > > > > > > > >=20 > > > > > > > > Other people think 30s about this, you think years about th= at. > > > > > > > >=20 > > > > > > >=20 > > > > > > > It is the basis for my two decades long primary research into > > > > > > > termination analysis. People on another forum have written > > > > > > > hundreds of posts claiming that D correctly simulated by H > > > > > > > reaches its own line 06 and halts. > > > > > > >=20 > > > > > > > *I have only gotten truthful answers on this forum* > > > > > > >=20 > > > > > >=20 > > > > > > That's not research, that's nonsense. > > > > > >=20 > > > > >=20 > > > > > This is not the forum to show that it is not nonsense this is > > > > > a simple C question that I should not even have to ask except > > > > > for a few people in another forum that consistently lie about > > > > > the answer. > > > > >=20 > > > > > I have been a professional C++ developer since Y2K. So I already > > > > > know the answer, I just need some competent people in this forum > > > > > to attest to this answer. I met Bjarne Stroustrup back when he > > > > > was going around the country promoting his new language. > > > > >=20 > > > >=20 > > > > typedef int (*ptr)();=C2=A0 // ptr is pointer to int function > > > > int H(ptr x, ptr y); > > > > int D(ptr x) > > > > { > > > > =C2=A0=C2=A0=C2=A0 int Halt_Status =3D H(x, x); > > > > =C2=A0=C2=A0=C2=A0 if (Halt_Status) > > > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 HERE: goto HERE; > > > > =C2=A0=C2=A0=C2=A0 return Halt_Status; > > > > } > > > >=20 > > > > int main() > > > > { > > > > =C2=A0=C2=A0=C2=A0 H(D,D); > > > > =C2=A0=C2=A0=C2=A0 return 0; > > > > } > > > >=20 > > > > The code above does not compile: > > >=20 > > > *It does compile* > > > *It does compile* > > > *It does compile* > > > *It does compile* > > >=20 > > > typedef int (*ptr)(); > > > int H(ptr P, ptr I); > > >=20 > > > int D(ptr x) > > > { > > > =C2=A0=C2=A0=C2=A0 int Halt_Status =3D H(x, x); > > > =C2=A0=C2=A0=C2=A0 if (Halt_Status) > > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 HERE: goto HERE; > > > =C2=A0=C2=A0=C2=A0 return Halt_Status; > > > } > > >=20 > > > int main() > > > { > > > =C2=A0=C2=A0=C2=A0 H(D,D); > > > =C2=A0=C2=A0=C2=A0 return 0; > > > } > > >=20 > > > cl=C2=A0 /GS- /std:c11 /c /arch:IA32 Test_Compile.c > > > cl=C2=A0 /GS- /std:c17 /c /arch:IA32 Test_Compile.c > > > if ERRORLEVEL 1 pause > > >=20 > > >=20 > > > D:\__HP_Stream\__NLU_Notes\__Work_In_Progress\__Halt_Decider_X86\___x= 86utm_VS>echo > > > off > > >=20 > > > D:\__HP_Stream\__NLU_Notes\__Work_In_Progress\__Halt_Decider_X86\___x= 86utm_VS>REM > > > 2022 > > >=20 > > > D:\__HP_Stream\__NLU_Notes\__Work_In_Progress\__Halt_Decider_X86\___x= 86utm_VS>call > > > "C:\Program Files\Microsoft Visual > > > Studio\2022\Community\Common7\Tools\VsDevCmd.BAT" > > > *********************************************************************= * > > > ** Visual Studio 2022 Developer Command Prompt v17.6.4 > > > ** Copyright (c) 2022 Microsoft Corporation > > > *********************************************************************= * > > > Microsoft (R) C/C++ Optimizing Compiler Version 19.36.32535 for x86 > > > Copyright (C) Microsoft Corporation.=C2=A0 All rights reserved. > > >=20 > > > Test_Compile.c > > > Microsoft (R) C/C++ Optimizing Compiler Version 19.36.32535 for x86 > > > Copyright (C) Microsoft Corporation.=C2=A0 All rights reserved. > > >=20 > > > Test_Compile.c > > > Press any key to continue . . . > >=20 > > OK, My fault, gcc can compile (g++ can't. No idea why D's protocol does= n't match > > type ptr and get compiled in C). > >=20 >=20 >=20 > 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. ========== REMAINDER OF ARTICLE TRUNCATED ==========