[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: MIT discovered issue with gcc



On Sun, Dec 01, 2013 at 11:18:47PM +0900, Joel Rees wrote:
> optimizer's excuse to silently kill undefined behavior code.

As far as I know, all examples I have seen this is not what
happens.  What happens is that the compiler assumes you write code
that has defined behavior and optimises based on the assumptions
of that defined behavior.  And if it happens that it's undefined
behavior it might do the wrong thing.  It can for instance then
come to conclusion that that code can not be executed and so can
be safely removed.

The making of the assumptions is a problem since it doesn't
always have a way of checking those assumptions.  And it had, it
might be complicated to turn that back into a warning.

Please note that making those assumptions is an important thing to
do for a C compiler to be able to generate fast code.  There is
lots of code where you _might_ run into undefined behavior but
never do because of how the code is called.  And the compiler
assumes that you only call it in defined cases.


Kurt


Reply to: