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

            Bug ID: 93386
           Summary: Missing a const qualifier in the type denoted by
                    decltype((r))
           Product: gcc
           Version: 9.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: kyle.show910 at gmail dot com
  Target Milestone: ---

According to the standard
timsong-cpp.github.io/cppwp/n4659/expr.prim.lambda.capture#14, we should have
the following:
void f3() {
  float x, &r = x;
  [=] {                     
    decltype(x) y1;         // y1 has type float
    decltype((x)) y2 = y1;  // y2 has type float const& because this lambda is
not mutable and x is an lvalue
    decltype(r) r1 = y1;    // r1 has type float& (transformation not
considered)
    decltype((r)) r2 = y2;  // r2 has type float const&
  };
}
but we have this:
void f3() {
  float x, &r = x;
  [=] {                     
    decltype(x) y1;         // y1 has type float
    decltype((x)) y2 = y1;  // y2 has type float const&
    decltype(r) r1 = y1;    // r1 has type float&
    decltype((r)) r2 = y2;  // r2 has type float&
  };
}
https://godbolt.org/z/sYXzzn
https://godbolt.org/z/unpxwV

The type denoted by decltype((r)) where r is a reference and decltype occurs
inside a const member function doesn’t contain a const qualifier.

Reply via email to