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++/54777] New: [C++11] Comma operator in constexpr environment can cause ICE


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

             Bug #: 54777
           Summary: [C++11] Comma operator in constexpr environment can
                    cause ICE
    Classification: Unclassified
           Product: gcc
           Version: 4.8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: daniel.kruegler@googlemail.com


Using gcc 4.8.0 20120923 (experimental) and compiler flags

-Wall -pedantic -std=c++11

the following code gives an ICE:

//-------------
struct array {
    int data[1];
    constexpr const int& at(unsigned i)
    {
      return (i < 1 ? 0 : throw 1), data[i];
      //return i < 1 ? data[i] : (throw 0, data[i]); // OK
    }
};

int main() {
  constexpr array a{};
  constexpr int i = a.at(0);
}
//-------------

"
main.cpp||In function 'int main()':|
main.cpp|12|  in constexpr expansion of 'a.array::at(0u)'|
main.cpp|12|internal compiler error: in adjust_temp_type, at
cp/semantics.c:6425|
"

The code should be accepted.


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