http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46619
--- Comment #11 from Eskil Steenberg <eskil at obsession dot se> 2010-11-23 21:29:12 UTC --- Hi Again! > http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46619 > > --- Comment #10 from Andrew Pinski <pinskia at gcc dot gnu.org> 2010-11-23 > 20:24:00 UTC --- > uv = (unsigned int)((int)x[1 + j] * (int)x[1 + i]); > > Is what the C standard says should be done as unsigned short is smaller > than int so it is promoted to int. ^^^ Yes, but it ISNT an int, its an unsigned int. double is also bigger then unsigned short, why not promote it to double if we are bringing in random types? > So we have a 16x16 unsigned to a 31+1 > multiple which can overflow. Assuming the silliness above is right, it still shouldn't matter. If it can overflow it means that the product value of the two positive x values can be negative, and then in turn would become bigger then max signed int when it gets converted to a unsigned int (uv) from the type int where you claim the multiplication should be made, making it illegal to optimize away the later line. If you read out the data after the line doing the addition it outputs a unsinged int value larger then max signed int. So the compiler thinks something could never happen that clearly happens when you run the code. Cheers E