public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "regehr at cs dot utah dot edu" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c/40762] New: possible integer miscompilation Date: Wed, 15 Jul 2009 06:33:00 -0000 [thread overview] Message-ID: <bug-40762-12544@http.gcc.gnu.org/bugzilla/> (raw) Seen on Ubuntu Hardy. The -O2 result seems to be wrong. Also valgrind says this about the -O2 compilation: ==6729== Conditional jump or move depends on uninitialised value(s) ==6729== at 0x84F22CB: solve_graph (tree-ssa-structalias.c:1570) regehr@john-home:~/volatile/tmp174$ current-gcc -O1 small.c -o small regehr@john-home:~/volatile/tmp174$ ./small checksum = 0 regehr@john-home:~/volatile/tmp174$ current-gcc -O2 small.c -o small regehr@john-home:~/volatile/tmp174$ ./small checksum = 1 regehr@john-home:~/volatile/tmp174$ current-gcc -v Using built-in specs. Target: i686-pc-linux-gnu Configured with: ../configure --prefix=/home/regehr/z/tmp/gcc-r149650-install --program-prefix=r149650- --enable-languages=c,c++ Thread model: posix gcc version 4.5.0 20090714 (experimental) (GCC) regehr@john-home:~/volatile/tmp174$ cat small.c #include <stdint.h> #include <limits.h> #include <stdio.h> uint8_t g_4; int64_t g_10; uint8_t g_56; uint8_t g_64; static uint8_t safe_rshift_func_uint8_t_u_u(uint8_t left, unsigned int right) { return ((((unsigned int)(right)) >= sizeof(uint8_t)*CHAR_BIT) ? ((uint8_t)(left)) : (((uint8_t)(left)) >> ((unsigned int)(right)))); } int32_t func_53 (void); int32_t func_53 (void) { if (safe_rshift_func_uint8_t_u_u (g_56, g_10)) { } else for (g_10 = 0; g_10; g_10 = 1) { } return 1; } int32_t func_36 (void); int32_t func_36 (void) { uint8_t p_40; g_10 = 1; g_10 && func_53 (); p_40 = g_10 || g_4; g_64 = g_10; return 1; } int main (void) { func_36 (); printf ("checksum = %d\n", g_64); return 0; } -- Summary: possible integer miscompilation Product: gcc Version: 4.5.0 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=40762
next reply other threads:[~2009-07-15 6:33 UTC|newest] Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top 2009-07-15 6:33 regehr at cs dot utah dot edu [this message] 2009-07-15 7:46 ` [Bug c/40762] " steven at gcc dot gnu dot org 2009-07-15 10:09 ` rguenth at gcc dot gnu dot org 2009-07-15 10:10 ` rguenth at gcc dot gnu dot org 2009-07-15 10:17 ` [Bug middle-end/40762] [4.5 Regression] CD-DCE messes up virtual SSA form rguenth at gcc dot gnu dot org 2009-09-07 10:24 ` rguenth at gcc dot gnu dot org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-40762-12544@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).