This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug middle-end/55481] [4.8 regression] -O2 generates a wrong-code infinite loop in C++Benchmark's simple_types_constant_folding int8 xor test
- From: "rguenth at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 27 Nov 2012 11:12:03 +0000
- Subject: [Bug middle-end/55481] [4.8 regression] -O2 generates a wrong-code infinite loop in C++Benchmark's simple_types_constant_folding int8 xor test
- Auto-submitted: auto-generated
- References: <bug-55481-4@http.gcc.gnu.org/bugzilla/>
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).