|
|
Subscribe / Log in / New account

Who's afraid of a big bad optimizing compiler?

Who's afraid of a big bad optimizing compiler?

Posted Jul 18, 2019 9:01 UTC (Thu) by mathstuf (subscriber, #69389)
In reply to: Who's afraid of a big bad optimizing compiler? by dunlapg
Parent article: Who's afraid of a big bad optimizing compiler?

> Since we don't know what hardware will do on signed integer overflow

You're writing C for a C abstract machine. That machine has undefined behavior for signed integer overflow. Undefined behavior in C means "all bets are off". If this is not what you want, don't use C, convince compilers to provide a "sensible C" dialect, or change C via the standards committee.


to post comments

Who's afraid of a big bad optimizing compiler?

Posted Jul 18, 2019 17:48 UTC (Thu) by mpr22 (subscriber, #60784) [Link]

In the particular case of signed integer overflow, of course, compilers already provide two "sensible C" dialects (gcc calls them -fwrapv and -ftrapv).

Who's afraid of a big bad optimizing compiler?

Posted Jul 22, 2019 12:06 UTC (Mon) by rweikusat2 (subscriber, #117920) [Link]

The C standard uses an abstract machine to define the semantics of the language. But real code is certainly not written to run on "abstract machines" and the C standard also contains the nice statement that "a conforming program is one acceptable to a conforming implementation". That's not the same as a strictly conformimg program (another term from the C standard) which would restrict itself to the functionality defined in this document.


Copyright © 2025, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds