[SystemSafety] Critical systems Linux
Olivier Andrieu
olivier.andrieu at esterel-technologies.com
Fri Nov 23 16:30:04 CET 2018
On Fri, Nov 23, 2018 at 4:05 PM Olwen Morgan olwen at phaedsys.com
<http://mailto:olwen@phaedsys.com> wrote:
> On 23/11/2018 12:33, Olivier Andrieu wrote:
>
>
> I’m not sure why you’re making this about the compilers. This program has
> unequivocally an undefined behavior, so, whatever a compiler does, it’s not
> wrong.
>
> Clang doesn’t even require an explicit warning option to point it out:
>
> $ clang se.c
> se.c:14:19: warning: multiple unsequenced modifications to 'i' [-Wunsequenced]
> PrintEvalOrder((++i), (++i), (++i));
> ^ ~~1 warning generated.
>
>
> gcc gives a similar warning but still gets the compiled code wrong, AFAI
> can infer, by being gung-ho with optimisation.
>
> As regards behaviour, AFAI can see it's not "undefined" but is covered by
> "unspecified" or "implementation-defined" behaviour (Derek Jones may
> correct me here.)
>
It’s undefined, it corresponds to this case from the ‘Portability issues’
annex of C99:
*« Between two sequence points, an object is modified more than once, or is
modified and the prior value is read other than to determine the value to
be stored (6.5) »*
—
Olivier
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.techfak.uni-bielefeld.de/mailman/private/systemsafety/attachments/20181123/d2cd5d15/attachment.html>
More information about the systemsafety
mailing list