This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/81354] New: Segmentation fault in SSA Strength Reduction using -O3


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81354

            Bug ID: 81354
           Summary: Segmentation fault in SSA Strength Reduction using -O3
           Product: gcc
           Version: 5.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jgrossma at qti dot qualcomm.com
  Target Milestone: ---

The following is a complete testcase:

 struct T { double a; double b; };

 void foo(T Ad[], int As[2])
 {
  int j;
  int i;
  int Bs[2] = {0,0};
  T Bd[16];

  for (j = 0; j < 4; j++) {
    for (i = 0; i + 1 <= j + 1; i++) {
      Ad[i + As[0] * j] = Bd[i + Bs[0] * j];
    }

    i = j + 1;  // <- comment out this line and it does not crash
    for (; i + 1 < 5; i++) {
      Ad[i + As[0] * j].a = 0.0;
      Ad[i + As[0] * j].b = 0.0;
    }
  }
 }

This crashes when compiled as follows:

$ g++ -c test.cpp -O3

test.cpp: In function ‘void foo(T*, int*)’:
test.cpp:3:6: internal compiler error: Segmentation fault
 void foo(T Ad[], int As[2])
      ^
0xaf6acf crash_signal
        ../../gcc/toplev.c:383
0xfef7b0 record_phi_increments
        ../../gcc/gimple-ssa-strength-reduction.c:2590
0xfef795 record_phi_increments
        ../../gcc/gimple-ssa-strength-reduction.c:2601
0xfef8f9 record_increments
        ../../gcc/gimple-ssa-strength-reduction.c:2638
0xff1e02 analyze_candidates_and_replace
        ../../gcc/gimple-ssa-strength-reduction.c:3594
0xff1e02 execute
        ../../gcc/gimple-ssa-strength-reduction.c:3681

This is in GCC 5.4.0 on Linux x86_64 (SuSE 11).

Removing the line:

  i = j + 1;  // <- comment out this line and it does not crash

[which leaves the code functionally equivalent] removes the crash. Dropping
down to -O2 or turning on -fno-strict-aliasing also removes the crash.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]