------- Comment #5 from rguenth at gcc dot gnu dot org 2009-07-29 18:12 ------- long lo_b_2268X; long lo_a_2267X; long lo_c_2271X; ... lo_a_2267X = 65535 & a_1962X; lo_b_2268X = 65535 & b_2266X; ... lo_c_2271X = ((lo_a_2267X) * (lo_b_2268X)); ... if ((536870911 < lo_c_2271X)) { ... else { if ((lo_c_2271X < 0)) {
as these are all signed quantities the multiplication in lo_c_2271X = ((lo_a_2267X) * (lo_b_2268X)) if overflowing invokes undefined behavior according to the C language standard. Thus the compiler assumes that multiplying two positive signed values is always positive. Use -fwrapv if you want twos-complement semantics for signed integers. -- rguenth at gcc dot gnu dot org changed: What |Removed |Added ---------------------------------------------------------------------------- Status|WAITING |RESOLVED Resolution| |INVALID http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40907