Mail Archives: djgpp-workers/1998/11/17/09:19:54
On Tue, 17 Nov 1998, Laszlo Molnar wrote:
> Let's say I have a 32-bit unsigned integer, and I want to clear it's
> most significant bit. I wrote this code:
>
> (x*2)/2
>
> And of course(?) it doesn't work. Is it a bug in gcc or a bug in me?
Did you compile with -O? Did you look at the assembly produced by GCC?
It is quite possible that the optimizer optimized this into oblivion.
Try this:
volatile int x;
x *= 2;
x /= 2;
Does this help?
- Raw text -