Paavo Helde <
eesnimi@osa.pri.ee> writes:
On 23.05.2024 21:13, James Kuyper wrote:
On 5/23/24 02:23, Paavo Helde wrote:
...
There are zillions of ways to write non-conforming code, for
example an endless loop is not conforming in C++.
Citation, please? How does it fail to conform?
It may well be I messed up something. I had a vague memory that g++
could legally optimize away the code only because it contained UB,
but now I'm not so sure any more.
Just briefly:
The rules are different in C and C++.
Endless loops are allowed in both languages.
I won't say any more about C except to emphasize that it has
different rules (than C++ does) with respect to endless loops.
It should go without saying that any program that crosses over
into undefined behavior might do anything at all. However I'm
pretty sure that there was no undefined behavior in the programs
being considered here.
In C++, endless loops that satisfy certain properties may be
assumed by the compiler to terminate, regardless of whether they
do or not. That statement applies whether or not there are any
iteration statements involved.
In the particular case of a statement such as
HERE: goto HERE;
a C++ compiler is within its rights to treat this statement as
though it were
HERE: ;
to the best of my understanding of the C++ standard.
(Since the thread has lost the code example being discusses I
have nothing more to say about that code.)
I hope these comments help clarify the matter.
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)