public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/110211] New: Local lambda treated as non-local
@ 2023-06-11 16:42 johelegp at gmail dot com
2023-06-11 16:51 ` [Bug c++/110211] " johelegp at gmail dot com
0 siblings, 1 reply; 2+ messages in thread
From: johelegp at gmail dot com @ 2023-06-11 16:42 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110211
Bug ID: 110211
Summary: Local lambda treated as non-local
Product: gcc
Version: 14.0
Status: UNCONFIRMED
Keywords: c++-lambda, rejects-valid
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: johelegp at gmail dot com
CC: johelegp at gmail dot com
Target Milestone: ---
See <https://compiler-explorer.com/z/W9PzEcc1v>.
```C++
template<class F, class T> concept invocable = requires(F f, T x) { f(x); };
static_assert(!invocable<
decltype([]<class T>(T) -> decltype([&]<class U>(U x)
requires requires { x.a();
}
{}(T())) {}),
int>);
```
```output
<source>:3:52: error: non-local lambda expression cannot have a capture-default
3 | decltype([]<class T>(T) -> decltype([&]<class U>(U x)
| ^
Compiler returned: 1
```
According to <https://eel.is/c++draft/expr.prim.lambda#capture-3>, this should
work.
If the `static_assert` is in a function, it still fails:
<https://compiler-explorer.com/z/b7rdqfxed>.
It fails on GCC10: <https://compiler-explorer.com/z/znsYvKdz1>.
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Bug c++/110211] Local lambda treated as non-local
2023-06-11 16:42 [Bug c++/110211] New: Local lambda treated as non-local johelegp at gmail dot com
@ 2023-06-11 16:51 ` johelegp at gmail dot com
0 siblings, 0 replies; 2+ messages in thread
From: johelegp at gmail dot com @ 2023-06-11 16:51 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110211
Johel Ernesto Guerrero Peña <johelegp at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Known to fail| |9.5.0
--- Comment #1 from Johel Ernesto Guerrero Peña <johelegp at gmail dot com> ---
Simplified:
- GCC 9.5 <https://compiler-explorer.com/z/PTr9Tbe5G>.
- GCC trunk <https://compiler-explorer.com/z/5cbEMvEvo>.
```C++
int main() {
[](auto x) -> decltype([&](auto) {}(x)) {}(0);
}
```
With this, MSVC fails.
Apparently, rather than a hard error, it fails OR.
That must be why it passed before.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-06-11 16:51 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-11 16:42 [Bug c++/110211] New: Local lambda treated as non-local johelegp at gmail dot com
2023-06-11 16:51 ` [Bug c++/110211] " johelegp at gmail dot com
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).