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

            Bug ID: 90212
           Summary: [8/9 Regression] by-ref capture of constexpr class
                    object rejected
           Product: gcc
           Version: 8.3.1
            Status: UNCONFIRMED
          Keywords: rejects-valid
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: redi at gcc dot gnu.org
                CC: nathan at gcc dot gnu.org
  Target Milestone: ---

template<typename T> struct tuple {
    constexpr tuple(T&& t) : t(t) { }
    int t;
};

void foo() {
    constexpr tuple<int> v1{1};
    constexpr auto v2 = v1;
    [&]{ constexpr auto v2 = v1; };
}

Since r256842 GCC 8 and trunk reject this:


a.cc: In lambda function:
a.cc:9:30: error: lambda capture of ‘v1’ is not a constant expression
     [&]{ constexpr auto v2 = v1; };
                              ^~

Clang and icc accept it, and I think it's valid.

Reply via email to