public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "regehr at cs dot utah.edu" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c/47148] New: likely wrong code bug
Date: Sat, 01 Jan 2011 18:40:00 -0000	[thread overview]
Message-ID: <bug-47148-4@http.gcc.gnu.org/bugzilla/> (raw)

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47148

           Summary: likely wrong code bug
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: regehr@cs.utah.edu
                CC: chenyang@cs.utah.edu
              Host: x86_64-unknown-linux-gnu
            Target: x86_64-unknown-linux-gnu
             Build: x86_64-unknown-linux-gnu


[regehr@gamow tmp436]$ current-gcc -O1 small.c -o small 
[regehr@gamow tmp436]$ ./small
0
[regehr@gamow tmp436]$ current-gcc -O2 small.c -o small
[regehr@gamow tmp436]$ ./small
1
[regehr@gamow tmp436]$ current-gcc -v
Using built-in specs.
COLLECT_GCC=current-gcc
COLLECT_LTO_WRAPPER=/uusoc/exports/scratch/regehr/z/compiler-install/gcc-r168380-install/bin/../libexec/gcc/x86_64-unknown-linux-gnu/4.6.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ../configure --with-libelf=/usr/local --enable-lto
--prefix=/home/regehr/z/compiler-install/gcc-r168380-install
--program-prefix=r168380- --enable-languages=c,c++
Thread model: posix
gcc version 4.6.0 20101231 (experimental) (GCC) 
[regehr@gamow tmp436]$ cat small.c


int printf(const char *format, ...);

static unsigned div(unsigned p1, unsigned p2)
{
  return p1 / p2;
}

static unsigned rshift (unsigned p1, unsigned p2)
{
  if (p2 >= 32)
    return p1;
  else
    return p1 >> p2;
}

static unsigned g_26 = 1;
static unsigned g_78 = 1;

static void func_28 (unsigned char p_30, unsigned p_31)
{
  if (p_31) {
    unsigned l1 = div (0x7000, p_30-2) ^ g_26;
    unsigned l2 = rshift (g_26, g_26);
    unsigned l4 = g_26 - l2;
    g_78 &= (l4 && (g_26-1)) + l1;
  } 
}

static void func_2 (void)
{
  func_28 (1, 1);
}

int main(void)
{
  func_2();
  func_28 (-1, 1);
  printf("%d\n", g_78);
  return 0;
}


             reply	other threads:[~2011-01-01 18:40 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-01 18:40 regehr at cs dot utah.edu [this message]
2011-01-01 20:07 ` [Bug tree-optimization/47148] [4.6 Regression] " jakub at gcc dot gnu.org
2011-01-01 20:17 ` hjl.tools at gmail dot com
2011-01-01 20:54 ` [Bug target/47148] " jakub at gcc dot gnu.org
2011-01-01 21:03 ` hjl.tools at gmail dot com
2011-01-01 21:09 ` jakub at gcc dot gnu.org
2011-01-02 11:29 ` jakub at gcc dot gnu.org
2011-01-03 21:10 ` jakub at gcc dot gnu.org
2011-01-03 21:13 ` jakub at gcc dot gnu.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-47148-4@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: link
Be 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).