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

Patrick Palka <ppalka at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |INVALID
             Status|UNCONFIRMED                 |RESOLVED

--- Comment #2 from Patrick Palka <ppalka at gcc dot gnu.org> ---
I believe GCC 14 is behaving correctly according to the standard now.

According to https://eel.is/c++draft/expr.prim.lambda#capture-note-7,
decltype(source) must be S not S&, despite the by-ref capture.  And a
decltype(auto) deduced return type is equivalent decltype(return-expr), so it
must deduce to S here as well.  GCC's previous behavior was inconsistent and
incorrect in the decltype(auto) case.

Doing an init-capture [&source = source] yields S& because in that case there
is no "original entity" (the init-capture is its own independent entity), and
the note doesn't apply, I think.

See also
https://stackoverflow.com/questions/33854388/decltypeauto-deduced-return-type-from-lambda-capture

Reply via email to