This is the mail archive of the gcc-bugs@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]

Re: Compiler bug....


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

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