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

            Bug ID: 71226
           Summary: ICE in fold_binary_loc, at fold-const.c:9252,  from
                    constexpr function
           Product: gcc
           Version: 6.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: gccbug at kundor dot org
  Target Milestone: ---

Created attachment 38542
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=38542&action=edit
preprocessed source

This code causes an internal compiler error with GCC 6.1:

struct zero {
   int m_data[1];

   constexpr zero() : m_data{} {}
};

constexpr zero foo(zero a) {
   a.m_data[0] += a.m_data[0];
   return a;
}

int main() {
    constexpr zero x;
    constexpr zero y = foo(x);
    return 0;
}

The output is 

consterr.cpp: In function 'int main()':
consterr.cpp:14:29:   in constexpr expansion of 'foo(x)'
consterr.cpp:14:29: internal compiler error: in fold_binary_loc, at
fold-const.c:9252
     constexpr zero y = foo(x);
                             ^

consterr.cpp:14:29: internal compiler error: Abort trap: 6
g++-mp-6: internal compiler error: Abort trap: 6 (program cc1plus)
Please submit a full bug report...

I am on x86_64-apple-darwin15, but I have verified the same error occurs on
other platforms (https://godbolt.org/g/ebCznR ,
http://coliru.stacked-crooked.com/a/ca262ac3ffb4313b)

G++ 5.3.0 also hits an internal compiler error, but just reports

consterr.cpp:14:29: internal compiler error: Segmentation fault: 11

(no mention of fold_binary_loc.)

Reply via email to