http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55481
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Depends on| |35634
--- Comment #7 from Richard Biener <rguenth at gcc dot gnu.org> 2012-11-27
11:12:03 UTC ---
Note that the frontends warn with
lucky13x.c: In function 'int main(int, char**)':
lucky13x.c:24:64: warning: overflow in implicit constant conversion
[-Woverflow]
int8_t temp = (int8_t)SIZE * ((int8_t)(23) | (int8_t)(10));
when manually inlining do_shift at the checking point:
int8_t temp = (int8_t)SIZE * ((int8_t)(23) | (int8_t)(10));
if (result != temp)
abort ();
this computes 13 * 31 which is 403 so the warning is correct. Fixed with
an extra cast. This also means that
for (n = 0; n < SIZE; ++n)
result += do_shift( first[n] );
triggers the bug about doing the addition in the wrong type and the bug
is fixed by rewriting this as
result = result + do_shift (first[n]);
that is, self-modify is not correctly doing the addition in 'int'. And thus
this is a dup of PR35634 I believe (-fwrapv also fixes this).