On Sat, Jul 01, 2006 at 12:41:54AM +0200, Vincent Fourmond wrote:
> There definitely *is* a problem in the last iteration. I wonder if it is a compiler bug or a
> processor bug -- I can't speak assembler anymore.
This rather looks like UB or such.
> int main()
> {
> unsigned long iters;
> int i;
> for (i = 0; i < 32; i++) {
> iters = 1 << (unsigned long) i;
Hmm, I'm pretty sure that the type of "signed int" << "unsigned long" is
"signed int". (Yes it is, see 6.5.7.) "signed int" is 32 bits long and
the largest value is 2^31-1. 2^31 overflows and the overflow behaviour
of signed integers is undefined.
> printf("iteration %d, iters = %lu\n", i, iters);
> }
> }
This code produces undefined behavour.
Bastian
--
Our way is peace.
-- Septimus, the Son Worshiper, "Bread and Circuses",
stardate 4040.7.
Attachment:
signature.asc
Description: Digital signature