Bug 27173 - [4.0 regression] ICE with -O -ftrapv
Summary: [4.0 regression] ICE with -O -ftrapv
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: 4.0.3
: P3 normal
Target Milestone: 4.1.0
Assignee: Not yet assigned to anyone
URL:
Keywords: ice-on-valid-code, monitored
Depends on:
Blocks:
 
Reported: 2006-04-14 20:20 UTC by bagnara
Modified: 2007-02-03 16:51 UTC (History)
2 users (show)

See Also:
Host: i686-pc-linux-gnu
Target:
Build:
Known to work: 3.4.6 4.1.0
Known to fail: 4.0.1 4.0.3
Last reconfirmed: 2006-09-03 21:39:47


Attachments
Testcase that allows to reproduce the problem (150.36 KB, application/x-bzip2)
2006-04-14 20:22 UTC, bagnara
Details

Note You need to log in before you can comment on or make changes to this bug.
Description bagnara 2006-04-14 20:20:26 UTC
The attached program causes an ICE when compiled with both -O and -ftrapv:

$ g++ -O -ftrapv -c Linear_System.ii
g++: Internal error: Segmentation fault (program cc1plus)
Please submit a full bug report.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.
Comment 1 bagnara 2006-04-14 20:22:07 UTC
Created attachment 11274 [details]
Testcase that allows to reproduce the problem
Comment 2 Andrew Pinski 2006-04-14 21:17:51 UTC
Reducing.
Comment 3 Volker Reichelt 2006-04-19 20:07:03 UTC
Confirmed.

Reduced testcase (compile with "-O -ftrapv"):

==================================
char *p, *q;

inline int foo(int i)
{
  return (p - q) + i;
}

void bar()
{
  int n, i;

  for (n = 7; n-- > 0; )
    for (i = n; i-- > 0; )
      if (i)
        p += -foo(i-1);
}
==================================

The testcase eats more than 2 GB of memory within seconds.
This happens with C and C++ frontend.

The bug only affects the 4.0 branch.
Comment 4 Volker Reichelt 2006-05-03 10:56:36 UTC
The testcase in comment #3 only crashes on x86_64-unknown-linux-gnu,
but not on i686-pc-linux-gnu.

The testcase below crashes on both archs:

===================================
char *p, *q;

inline int foo(int i)
{
  int j = (p - q) + i;
  return -j;
}

void bar()
{
  int n, i;

  for (n = 7; n-- > 0; )
    for (i = n; i-- > 0; )
      if (i)
        p += foo(i-1);
}
===================================
Comment 5 Gabriel Dos Reis 2007-02-03 16:51:00 UTC
Fixed in GC-4.1.0.