This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/42721] New: possible integer wrong code bug
- From: "regehr at cs dot utah dot edu" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 13 Jan 2010 03:54:25 -0000
- Subject: [Bug c/42721] New: possible integer wrong code bug
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
Seen on Ubuntu 9.10. I think "1" is the right answer.
regehr@john-home:~/volatile/bugs/tmp254$ current-gcc -O1 small.c -o small
regehr@john-home:~/volatile/bugs/tmp254$ ./small
checksum = 1
regehr@john-home:~/volatile/bugs/tmp254$ current-gcc -O2 small.c -o small
regehr@john-home:~/volatile/bugs/tmp254$ ./small
checksum = 0
regehr@john-home:~/volatile/bugs/tmp254$ current-gcc -v
Using built-in specs.
COLLECT_GCC=current-gcc
COLLECT_LTO_WRAPPER=/home/regehr/z/tmp/gcc-r155838-install/libexec/gcc/i686-pc-linux-gnu/4.5.0/lto-wrapper
Target: i686-pc-linux-gnu
Configured with: ../configure --with-libelf=/usr/local --enable-lto
--prefix=/home/regehr/z/tmp/gcc-r155838-install --program-prefix=r155838-
--enable-languages=c,c++
Thread model: posix
gcc version 4.5.0 20100112 (experimental) (GCC)
regehr@john-home:~/volatile/bugs/tmp254$ cat small.c
#include <stdint.h>
#include <stdio.h>
static uint64_t safe_div_uint64_t (uint64_t ui1, uint64_t ui2)
{
return (ui2 == 0) ? ui1 : (ui1 / ui2);
}
static int8_t safe_mod_int8_t (int8_t si1, int8_t si2)
{
return
((si2 == 0) || ((si1 == INT8_MIN) && (si2 == (-1)))) ?
si1 :
(si1 % si2);
}
static int32_t g_5;
static int32_t g_11;
int main (void)
{
uint64_t l_7 = 0x509CB0BEFCDF11BBLL;
g_11 ^= l_7 && ((safe_div_uint64_t ((safe_mod_int8_t (g_5, 0)), -1L)) != 1L);
printf ("checksum = %d\n", g_11);
return 0;
}
--
Summary: possible integer wrong code bug
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: regehr at cs dot utah dot edu
GCC build triplet: i686-pc-linux-gnu
GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42721