Re: Compile time checking of standards conformance

Liste des GroupesRevenir à l c 
Sujet : Re: Compile time checking of standards conformance
De : jameskuyper (at) *nospam* alumni.caltech.edu (James Kuyper)
Groupes : comp.lang.c comp.lang.c++
Date : 24. May 2024, 17:59:47
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <v2qdhj$2d2hf$1@dont-email.me>
References : 1 2 3 4
User-Agent : Mozilla Thunderbird
On 5/24/24 10:39, Paavo Helde wrote:
On 23.05.2024 21:13, James Kuyper wrote:
On 5/23/24 02:23, Paavo Helde wrote:
...
The C standard contains the following wording:
>
"An iteration statement may be assumed by the implementation to
terminate if its controlling expression is not a constant expression200)
, and none of the following operations are performed in its body,
controlling expression or (in the case of a for statement)
itsfexpression-3201) :
— input/output operations
— accessing a volatile object
— synchronization or atomic operations."
>
 
It looks like they have clarified the rules in the last standard, my
earlier draft (n4861) does not contain such verbiage.

I did a context change up above; you might have missed it. I'm talking
about the C standard, because it gives this permission, before pointing
out that the C++ standard does not. According to
<https://www.open-std.org/jtc1/sc22/wg14/www/wg14_document_log.htm>, the
highest C document number is currently n3265.

The latest public draft of the C++ standard is
<https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2023/n4950.pdf>

wg21 does not appear to have a document_log.htm like wg14, so I have not
been able to find n4861.pdf. I have a copy of n4860.pdf, which is a
draft of the C++ standard dated 2020-03-31.

In essence, those restrictions mean that the body of the loop does
nothing that need take up any time, so it can be optimized to a nop.
Infinitely many repetitions times 0 execution time has a product that is
mathematically meaningless, but the C standard permits optimizing to
terminate after a finite amount of time.
>
Note that this does not apply to endless loops occurring by other means,
such as goto.
 
The 4861 draft gives an implementation of a while loop in terms of GOTO
and says these are equivalent.

Note that the equivalence of those two constructs is not exact - for
instance, a continue statement is allowed only inside and actual
iteration statement, and not inside code that is otherwise equivalent,
but using goto.
Permission is given to conclude that iteration statements terminate. I
don't think the permission extends to equivalent constructs created
using goto.
Note that C is case sensitive language, so it's best not to capitalize
lower-case C keywords.

Date Sujet#  Auteur
23 May 24 * Compile time checking of standards conformance11olcott
23 May 24 `* Re: Compile time checking of standards conformance10Paavo Helde
23 May 24  +- Re: Compile time checking of standards conformance1olcott
23 May 24  +* Re: Compile time checking of standards conformance4olcott
23 May 24  i`* Re: Compile time checking of standards conformance3David Brown
23 May 24  i `* Re: Compile time checking of standards conformance2olcott
23 May 24  i  `- Re: Compile time checking of standards conformance1David Brown
23 May 24  +* Re: Compile time checking of standards conformance3James Kuyper
24 May 24  i`* Re: Compile time checking of standards conformance2Paavo Helde
24 May 24  i `- Re: Compile time checking of standards conformance1James Kuyper
24 May 24  `- Re: Compile time checking of standards conformance1Keith Thompson

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal