This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Optimisations and undefined behaviour


On 2015.11.05 at 21:52 +0100, David Brown wrote:
> There has been some discussions going on in the comp.lang.c newsgroup 
> about how far compilers are allowed to go regarding optimisation using 
> their knowledge of undefined behaviour (i.e., if a piece of code has 
> undefined behaviour, the compiler can assume that the user does not care 
> about the result in that case, and can therefore do whatever it wants in 
> order to generate faster code).

The compiler just assumes that undefined behavior will not happen and
optimizes accordingly.

Now that -fsanitize=undefined is available this shouldn't be a big issue
anymore.

For more details I recommend John Regehr's excellent blog entries on
this topic, e.g.: http://blog.regehr.org/archives/1234

-- 
Markus


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]