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++/66635] New: g++ ICE when compiling constexpr code with comma operator


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

            Bug ID: 66635
           Summary: g++ ICE when compiling constexpr code with comma
                    operator
           Product: gcc
           Version: 5.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: andreas at sandberg dot pp.se
  Target Milestone: ---

Use of the comma operator in constexpr environment causes ICE in g++ 5.1.0. The
following test case triggers the bug:

--- Begin test case ---

#include <cassert>

struct Foo {
    constexpr Foo(const unsigned i) : val(i) {}
    constexpr Foo operator-(const Foo &rhs) const {
        return assert(val >= rhs.val), Foo(val - rhs.val);
    }
    unsigned val;
};

constexpr Foo foo(Foo(1) - Foo(2));

--- End test case ---

I have been able to reproduce the bug on both Linux and MacOS for gcc version
5.1.0. A colleague tested this using trunk yesterday and the error still seems
to be present. g++ version 4.9.1 does not seem to suffer from this bug.

This seems to be closely related to bug 54777.


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