This is the mail archive of the gcc@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: GCC optimizes integer overflow: bug or feature?


On Thu, 21 Dec 2006, Ian Lance Taylor wrote:

> > Another question for the GCC experts: would it fix the bug
> > if we replaced "j *= 2" with "j <<= 1" in this sample code?
> 
> Well, mainline VRP isn't clever enough to understand that case.  But
> it doesn't make the code any more defined.  A left shift of a signed
> value to a value which can not be represented in the signed type is
> also undefined (C99 6.5.7).

As noted, it's only undefined in C99 not C90 and we document that this 
undefinedness isn't used at present; and non-front-end code can't use 
flag_isoc99 since it isn't available in non-C-family front ends.

-- 
Joseph S. Myers
joseph@codesourcery.com


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