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

            Bug ID: 89158
           Summary: [8/9 Regression] by-value capture of ICE variable
                    isn't an lvalue?
           Product: gcc
           Version: 8.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: eric at efcs dot ca
  Target Milestone: ---

The following code is incorrectly rejected.

// g++ -std=c++14
struct T { T(const int&); };
void Func(T);

void test() {
    constexpr int Val = 42;
    [Val]() { Func(Val); }; // error: lvalue required as unary '&' operand
}

My understanding is that `Val` is captured by copy, and the call to `Func`
makes it ODR used?

Regardless, I believe this code is well-formed and should be accepted.

It is accepted in 8.1, but rejected in 8.2 and trunk.

[1] https://godbolt.org/z/wrCQ53

Reply via email to