Compiler bug....
Scott Bambrough
scottb@netwinder.org
Fri Oct 29 05:54:00 GMT 1999
Why in this case does the literal have to be promoted? And why should
the behaviour differ with optimization?\
Scott
Nathan Sidwell wrote:
>
> dirk.derycke@icos.be wrote:
> >
> > I have the following strange error that occurs when compiling WITHOUT
> > optimizations
> >
> > const unsigned short shift = 32;
> > unsigned int res;
> >
> > res = 1 << shift;
> >
> > normally this fragment should cause an overflow and res should become zero
> Nope. (assuming unsigned int contains no more than 32 representable bits)
>
> 'If the value of the right operand is negative or is greater than
> or equal to the number of value and sign bits in the object
> representation of the promoted left operand, the behaviour is
> undefined.'
>
> nathan
>
> --
> Dr Nathan Sidwell :: Computer Science Department :: Bristol University
> I have seen the death of PhotoShop -- it is called GIMP
> nathan@acm.org http://www.cs.bris.ac.uk/~nathan/ nathan@cs.bris.ac.uk
--
Scott Bambrough - Software Engineer
REBEL.COM http://www.rebel.com
NetWinder http://www.netwinder.org
More information about the Gcc-bugs
mailing list