[Bug c++/83167] decltype((x)) inside lambda is considered odr-use if x is not a reference

2023-12-08 Thread ppalka at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83167

Patrick Palka  changed:

   What|Removed |Added

   Target Milestone|--- |14.0
 CC||ppalka at gcc dot gnu.org
 Status|UNCONFIRMED |RESOLVED
 Resolution|--- |FIXED
   Assignee|unassigned at gcc dot gnu.org  |ppalka at gcc dot 
gnu.org

--- Comment #4 from Patrick Palka  ---
Narrowly fixed for GCC 14, thanks for the bug report.

[Bug c++/83167] decltype((x)) inside lambda is considered odr-use if x is not a reference

2023-12-08 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83167

--- Comment #3 from GCC Commits  ---
The master branch has been updated by Patrick Palka :

https://gcc.gnu.org/g:d9965fef40794d548021d2e34844e5fafeca4ce5

commit r14-6350-gd9965fef40794d548021d2e34844e5fafeca4ce5
Author: Patrick Palka 
Date:   Fri Dec 8 16:57:13 2023 -0500

c++: decltype of (non-captured variable) [PR83167]

For decltype((x)) within a lambda where x is not captured, we dubiously
require that the lambda has a capture default, unlike for decltype(x).
But according to [expr.prim.id.unqual]/3 we should just ignore the lambda
in this case.  This patch narrowly fixes this issue by disabling the
capture_decltype handling and falling back to the ordinary handling when
the innermost lambda has no capture-default.  In fact, we can restrict
the special handling to only by-copy lambdas since that's what
[expr.prim.id.unqual]/3 is concerned with; for by-ref implicit captures
both code paths should give the same result anyway.

During review some other issues were discovered which are documented in
a new FIXME.

PR c++/83167

gcc/cp/ChangeLog:

* semantics.cc (capture_decltype): Inline into its only caller ...
(finish_decltype_type): ... here.  Update nearby comment to refer
to recent standard.  Add FIXME.  Restrict uncaptured variable type
transformation to happen only for lambdas with a by-copy
capture-default.

gcc/testsuite/ChangeLog:

* g++.dg/cpp0x/lambda/lambda-decltype4.C: New test.

[Bug c++/83167] decltype((x)) inside lambda is considered odr-use if x is not a reference

2022-10-26 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83167

--- Comment #2 from Andrew Pinski  ---
I might have seen a dup of this bug before.

[Bug c++/83167] decltype((x)) inside lambda is considered odr-use if x is not a reference

2021-08-07 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83167

Andrew Pinski  changed:

   What|Removed |Added

   See Also||https://gcc.gnu.org/bugzill
   ||a/show_bug.cgi?id=79620,
   ||https://gcc.gnu.org/bugzill
   ||a/show_bug.cgi?id=94376

--- Comment #1 from Andrew Pinski  ---
No compiler fully accepts this code.
clang fails on the 2nd and 4th asserts
ICC fails on the 2nd assert only
MSVC fails on all 4 asserts.
GCC fails on the first 2 asserts.

GCC is the only one that fails on the 1st assert via not being captured.