public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/53465] New: [4.7 regression] wrong code with -O1 -ftree-vrp
@ 2012-05-24  2:38 luto at mit dot edu
  2012-05-24  3:36 ` [Bug tree-optimization/53465] " hjl.tools at gmail dot com
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: luto at mit dot edu @ 2012-05-24  2:38 UTC (permalink / raw)
  To: gcc-bugs

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

             Bug #: 53465
           Summary: [4.7 regression] wrong code with -O1 -ftree-vrp
    Classification: Unclassified
           Product: gcc
           Version: 4.7.1
            Status: UNCONFIRMED
          Severity: major
          Priority: P3
         Component: tree-optimization
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: luto@mit.edu


This code aborts with -O1 -ftree-vrp.  It shouldn't.  gcc 4.6 is okay;
4_7-branch from today and trunk are both bad.

extern void abort();

static const char input[] = {1,2};

void test(char const *data, int len)
{
  int i;
  int found_x = 0;
  char prev_x;
  for(i = 0; i < len; i++) {
    char x = data[i];

    if (x == 0)
      break;

    if (found_x && x <= prev_x)
      abort();

    prev_x = x;
    found_x = 1;
  }
}

int main()
{
  test(input, 2);
  return 1;
}

Changing char x to volatile char x or initializing prev_x before the loop will
prevent the crash.


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2013-01-16 13:58 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-05-24  2:38 [Bug tree-optimization/53465] New: [4.7 regression] wrong code with -O1 -ftree-vrp luto at mit dot edu
2012-05-24  3:36 ` [Bug tree-optimization/53465] " hjl.tools at gmail dot com
2012-05-24  7:30 ` jakub at gcc dot gnu.org
2012-05-24  7:34 ` rguenther at suse dot de
2012-05-24  7:43 ` jakub at gcc dot gnu.org
2012-05-24  8:23 ` rguenther at suse dot de
2012-05-24  9:28 ` jakub at gcc dot gnu.org
2012-05-24 11:53 ` jakub at gcc dot gnu.org
2012-05-24 11:54 ` jakub at gcc dot gnu.org
2012-05-24 11:54 ` [Bug tree-optimization/53465] [4.7/4.8 Regression] " jakub at gcc dot gnu.org
2012-05-24 11:56 ` jakub at gcc dot gnu.org
2013-01-16 13:58 ` rguenth at gcc dot gnu.org

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).