public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/38819]  New: [4.2/4.3/4.4 Regression] trapping expression wrongly hoisted out of loop
@ 2009-01-12 20:55 jsm28 at gcc dot gnu dot org
  2009-01-13  9:51 ` [Bug tree-optimization/38819] " rguenth at gcc dot gnu dot org
                   ` (22 more replies)
  0 siblings, 23 replies; 25+ messages in thread
From: jsm28 at gcc dot gnu dot org @ 2009-01-12 20:55 UTC (permalink / raw)
  To: gcc-bugs

The following test wrongly fails with a floating point exception (division
by integer 0) when built with -O2 for i686-pc-linux-gnu.  Based on an
example posted by Robert Seacord to the WG14 reflector.  It works with 3.4 and
earlier, fails with 4.0 and later.  The % operation may trap if it is % 0
(or INT_MIN % -1, cf bug 30484 and another recent reflector discussion
suggesting INT_MIN % -1 should in fact be undefined in ISO C), so cannot be
hoisted above the loop unless it is guaranteed to be executed at least once.

extern void exit (int);
extern void abort (void);

volatile int a = 1;
volatile int b = 0;
volatile int x = 2;
volatile signed int r = 8;

void __attribute__((noinline))
foo (void)
{
  exit (0);
}

int
main (void)
{
  int si1 = a;
  int si2 = b;
  int i;

  for (i = 0; i < 100; ++i) {
    foo ();
    if (x == 8)
      i++;
    r += i + si1 % si2;
  }
  abort ();
}


-- 
           Summary: [4.2/4.3/4.4 Regression] trapping expression wrongly
                    hoisted out of loop
           Product: gcc
           Version: 4.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: jsm28 at gcc dot gnu dot org


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


^ permalink raw reply	[flat|nested] 25+ messages in thread
[parent not found: <bug-38819-4@http.gcc.gnu.org/bugzilla/>]

end of thread, other threads:[~2011-06-27 11:54 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-01-12 20:55 [Bug tree-optimization/38819] New: [4.2/4.3/4.4 Regression] trapping expression wrongly hoisted out of loop jsm28 at gcc dot gnu dot org
2009-01-13  9:51 ` [Bug tree-optimization/38819] " rguenth at gcc dot gnu dot org
2009-01-15 16:01 ` rguenth at gcc dot gnu dot org
2009-01-16 11:22 ` jakub at gcc dot gnu dot org
2009-01-16 11:41 ` rguenth at gcc dot gnu dot org
2009-01-16 20:05 ` rguenth at gcc dot gnu dot org
2009-01-16 20:25 ` rguenth at gcc dot gnu dot org
2009-01-16 20:44 ` pinskia at gcc dot gnu dot org
2009-01-16 20:48 ` dberlin at dberlin dot org
2009-01-16 21:01 ` rguenther at suse dot de
2009-01-16 21:07 ` dberlin at dberlin dot org
2009-01-16 22:25 ` rguenth at gcc dot gnu dot org
2009-01-16 22:26 ` rguenth at gcc dot gnu dot org
2009-01-16 22:51 ` rguenth at gcc dot gnu dot org
2009-01-18 15:49 ` [Bug tree-optimization/38819] [4.2/4.3 " rguenth at gcc dot gnu dot org
2009-01-18 15:51 ` rguenth at gcc dot gnu dot org
2009-02-08 18:00 ` ebotcazou at gcc dot gnu dot org
2009-03-31 21:07 ` [Bug tree-optimization/38819] [4.3 " jsm28 at gcc dot gnu dot org
2009-08-04 12:46 ` rguenth at gcc dot gnu dot org
2010-03-12 21:00 ` davem at gcc dot gnu dot org
2010-03-12 21:27 ` ebotcazou at gcc dot gnu dot org
2010-03-13 11:04 ` rguenth at gcc dot gnu dot org
2010-05-22 18:29 ` rguenth at gcc dot gnu dot org
2010-08-07  8:26 ` ubizjak at gmail dot com
     [not found] <bug-38819-4@http.gcc.gnu.org/bugzilla/>
2011-06-27 11:54 ` 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).