Compiler bug....

Nathan Sidwell nathan@acm.org
Fri Oct 29 05:17:00 GMT 1999


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


More information about the Gcc-bugs mailing list