[Bug c++/93842] generic lambda accesses a variable with with automatic storage duration that wasn't captured by the lambda expression
kuzniar95 at o2 dot pl
gcc-bugzilla@gcc.gnu.org
Tue Jun 16 16:42:14 GMT 2020
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93842
kuzniar95 at o2 dot pl changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |INVALID
Status|UNCONFIRMED |RESOLVED
--- Comment #5 from kuzniar95 at o2 dot pl ---
Actually everything is done well, my bad, sorry.
This code explains what's going on:
-------------------
void not_odr_use(char);
void odr_use(char&);
int main()
{
constexpr char ch1 = '=';
[] { not_odr_use(ch1); }; // compiles
[] { odr_use(ch1); }; // doesn't compile and it shouldn't
constexpr char ch2 = '=';
[](auto) { not_odr_use(ch2); }; // this line doesn't instantiate the
template (generic lambda is like a hidden template function) so "ch2" never
gets to be used
}
-------------------
I'm happy to close this and confirm that it isn't a compiler bug.
More information about the Gcc-bugs
mailing list