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]

Compiler bug.... (resent)



Hi,


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

but
without optimizations
res = 1;
the 1 bit seems to roll over and enters in the least significant bit

with optimizations
res = 0
(optimizer determines the CORRECT value at compile time)

Compiler version: 2.95.2
Platform : i686-pc-linux-gnu

I added the problem program with its makefile to this mail

regards,

Dirk De Rycke
dirk.derycke@icos.be

(See attached file: Makefile)(See attached file: shift.c)

Makefile

shift.c


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