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

            Bug ID: 64977
           Summary: GCC incorrectly rejects constexpr variable definition.
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ytj000 at gmail dot com

struct A {
    constexpr operator int() const { return 0; }
};

int main() {
    A a{};
    constexpr int b = a;             // ok
    [a]() { constexpr int b = a; };  // ok

    // error: the value of 'a' is not usable in a constant expression
    [&a]() { constexpr int b = a; }; 
}

GCC doesn't compile, clang compiles. (with -std=c++11)

Reply via email to