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

            Bug ID: 112926
           Summary: issues with nested lambdas and decltype of uncaptured
                    local variable
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ppalka at gcc dot gnu.org
  Target Milestone: ---

Here since the outer lambda has no capture-default, using x outside of an
unevaluated operand wouldn't capture it (despite the by-copy capture-default of
the inner lambda), so the special case in
https://eel.is/c++draft/expr.prim.id.unqual#3 doesn't apply and decltype((x)
should be int& not const int&.

int main() {
  int x;

  [] {
    [=] {
      using type = decltype((x)); // should be int& not const int&
      using type = int&;
    };
  };
}

Reply via email to