public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/114303] New: ICE with constexpr if and static_assert accessing captures across nested generic lambdas
@ 2024-03-11 11:07 benbarsdell at gmail dot com
2024-03-11 12:46 ` [Bug c++/114303] [11/12/13/14 Regression] " pinskia at gcc dot gnu.org
` (7 more replies)
0 siblings, 8 replies; 9+ messages in thread
From: benbarsdell at gmail dot com @ 2024-03-11 11:07 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114303
Bug ID: 114303
Summary: ICE with constexpr if and static_assert accessing
captures across nested generic lambdas
Product: gcc
Version: 14.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: benbarsdell at gmail dot com
Target Milestone: ---
Similar to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105788 but the
backtrace is different.
https://godbolt.org/z/xMPeTo633
Repros with the following versions on Godbolt:
14.0.1 ICE (gcc trunk on Godbolt)
13.2: ICE
13.1: ICE
12.3: ICE
12.2: OK
12.1: OK
11.4: ICE
11.3: OK
#include <type_traits>
int main() {
auto foo = [](auto level1) {
return [&](auto ) {
return [&](auto level3) {
if constexpr (decltype(level3)::value) {
static_assert(decltype(level1)::value, "");
}
return 0;
}(std::integral_constant<int, 1>());
}(0);
}(std::integral_constant<int, 1>());
}
<source>:8:17: internal compiler error: trying to capture 'level1' in
instantiation of generic lambda
8 | if constexpr (decltype(level3)::value) {
| ^~
0x265eabc internal_error(char const*, ...)
???:0
0xb86956 add_capture(tree_node*, tree_node*, tree_node*, bool, bool, unsigned
int*)
???:0
0xb869d9 add_default_capture(tree_node*, tree_node*, tree_node*)
???:0
0x16c682c walk_tree_1(tree_node**, tree_node* (*)(tree_node**, int*, void*),
void*, hash_set<tree_node*, false, default_hash_traits<tree_node*> >*,
tree_node* (*)(tree_node**, int*, tree_node* (*)(tree_node**, int*, void*),
void*, hash_set<tree_node*, false, default_hash_traits<tree_node*> >*))
???:0
0x16c68a9 walk_tree_1(tree_node**, tree_node* (*)(tree_node**, int*, void*),
void*, hash_set<tree_node*, false, default_hash_traits<tree_node*> >*,
tree_node* (*)(tree_node**, int*, tree_node* (*)(tree_node**, int*, void*),
void*, hash_set<tree_node*, false, default_hash_traits<tree_node*> >*))
???:0
0xc75f26 build_extra_args(tree_node*, tree_node*, int)
???:0
0xcab766 tsubst_lambda_expr(tree_node*, tree_node*, int, tree_node*)
???:0
0xc919b3 instantiate_decl(tree_node*, bool, bool)
???:0
0xb54725 maybe_instantiate_decl(tree_node*)
???:0
...
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/114303] [11/12/13/14 Regression] ICE with constexpr if and static_assert accessing captures across nested generic lambdas
2024-03-11 11:07 [Bug c++/114303] New: ICE with constexpr if and static_assert accessing captures across nested generic lambdas benbarsdell at gmail dot com
@ 2024-03-11 12:46 ` pinskia at gcc dot gnu.org
2024-03-11 12:48 ` [Bug c++/114303] [11/12/13/14 Regression] ICE with constexpr if and " pinskia at gcc dot gnu.org
` (6 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-03-11 12:46 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114303
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |ice-on-valid-code
Known to fail| |11.4.0, 12.3.0, 13.1.0
Known to work| |11.3.0, 12.1.0, 12.2.0
Summary|ICE with constexpr if and |[11/12/13/14 Regression]
|static_assert accessing |ICE with constexpr if and
|captures across nested |static_assert accessing
|generic lambdas |captures across nested
| |generic lambdas
Target Milestone|--- |11.5
Ever confirmed|0 |1
Status|UNCONFIRMED |NEW
Last reconfirmed| |2024-03-11
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Reduced testcase:
```
struct a
{
static constexpr int value = 1;
};
int main() {
[](auto level1) {
return [&](auto ) {
return [&](auto level3) {
if constexpr (decltype(level3)::value) {
static_assert(decltype(level1)::value, "");
}
return 0;
}(a{});
}(0);
}(a{});
}
```
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/114303] [11/12/13/14 Regression] ICE with constexpr if and accessing captures across nested generic lambdas
2024-03-11 11:07 [Bug c++/114303] New: ICE with constexpr if and static_assert accessing captures across nested generic lambdas benbarsdell at gmail dot com
2024-03-11 12:46 ` [Bug c++/114303] [11/12/13/14 Regression] " pinskia at gcc dot gnu.org
@ 2024-03-11 12:48 ` pinskia at gcc dot gnu.org
2024-03-11 14:43 ` ppalka at gcc dot gnu.org
` (5 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-03-11 12:48 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114303
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Note the static_assert is not needed, it could just be
`decltype(level1)::value` even.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/114303] [11/12/13/14 Regression] ICE with constexpr if and accessing captures across nested generic lambdas
2024-03-11 11:07 [Bug c++/114303] New: ICE with constexpr if and static_assert accessing captures across nested generic lambdas benbarsdell at gmail dot com
2024-03-11 12:46 ` [Bug c++/114303] [11/12/13/14 Regression] " pinskia at gcc dot gnu.org
2024-03-11 12:48 ` [Bug c++/114303] [11/12/13/14 Regression] ICE with constexpr if and " pinskia at gcc dot gnu.org
@ 2024-03-11 14:43 ` ppalka at gcc dot gnu.org
2024-03-15 15:01 ` law at gcc dot gnu.org
` (4 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: ppalka at gcc dot gnu.org @ 2024-03-11 14:43 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114303
Patrick Palka <ppalka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Assignee|unassigned at gcc dot gnu.org |ppalka at gcc dot gnu.org
Status|NEW |ASSIGNED
CC| |ppalka at gcc dot gnu.org
--- Comment #3 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Started with r13-6452 (which has been backported to 11/12).
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/114303] [11/12/13/14 Regression] ICE with constexpr if and accessing captures across nested generic lambdas
2024-03-11 11:07 [Bug c++/114303] New: ICE with constexpr if and static_assert accessing captures across nested generic lambdas benbarsdell at gmail dot com
` (2 preceding siblings ...)
2024-03-11 14:43 ` ppalka at gcc dot gnu.org
@ 2024-03-15 15:01 ` law at gcc dot gnu.org
2024-03-25 12:52 ` rguenth at gcc dot gnu.org
` (3 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: law at gcc dot gnu.org @ 2024-03-15 15:01 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114303
Jeffrey A. Law <law at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |law at gcc dot gnu.org
Priority|P3 |P1
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/114303] [11/12/13/14 Regression] ICE with constexpr if and accessing captures across nested generic lambdas
2024-03-11 11:07 [Bug c++/114303] New: ICE with constexpr if and static_assert accessing captures across nested generic lambdas benbarsdell at gmail dot com
` (3 preceding siblings ...)
2024-03-15 15:01 ` law at gcc dot gnu.org
@ 2024-03-25 12:52 ` rguenth at gcc dot gnu.org
2024-04-11 14:17 ` cvs-commit at gcc dot gnu.org
` (2 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu.org @ 2024-03-25 12:52 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114303
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Priority|P1 |P2
--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> ---
P2, we releases with this bug.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/114303] [11/12/13/14 Regression] ICE with constexpr if and accessing captures across nested generic lambdas
2024-03-11 11:07 [Bug c++/114303] New: ICE with constexpr if and static_assert accessing captures across nested generic lambdas benbarsdell at gmail dot com
` (4 preceding siblings ...)
2024-03-25 12:52 ` rguenth at gcc dot gnu.org
@ 2024-04-11 14:17 ` cvs-commit at gcc dot gnu.org
2024-04-12 20:04 ` [Bug c++/114303] [11/12/13 " ppalka at gcc dot gnu.org
2024-05-14 2:58 ` cvs-commit at gcc dot gnu.org
7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-04-11 14:17 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114303
--- Comment #5 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Patrick Palka <ppalka@gcc.gnu.org>:
https://gcc.gnu.org/g:b262b17636e47ae969a74f16e86ccb00678d5e88
commit r14-9916-gb262b17636e47ae969a74f16e86ccb00678d5e88
Author: Patrick Palka <ppalka@redhat.com>
Date: Thu Apr 11 10:16:41 2024 -0400
c++: build_extra_args recapturing local specs [PR114303]
r13-6452-g341e6cd8d603a3 made build_extra_args walk evaluated contexts
first so that we prefer processing a local specialization in an evaluated
context even if its first use is in an unevaluated context. But this
means we need to avoid walking a tree that already has extra args/specs
saved because the list of saved specs appears to be an evaluated
context which we'll now walk first. It seems then that we should be
calculating the saved specs from scratch each time, rather than
potentially walking the saved specs list from an earlier partial
instantiation when calling build_extra_args a second time around.
PR c++/114303
gcc/cp/ChangeLog:
* constraint.cc (tsubst_requires_expr): Clear
REQUIRES_EXPR_EXTRA_ARGS before calling build_extra_args.
* pt.cc (tree_extra_args): Define.
(extract_locals_r): Assert *_EXTRA_ARGS is empty.
(tsubst_stmt) <case IF_STMT>: Clear IF_SCOPE on the new
IF_STMT. Call build_extra_args on the new IF_STMT instead
of t which might already have IF_STMT_EXTRA_ARGS.
gcc/testsuite/ChangeLog:
* g++.dg/cpp1z/constexpr-if-lambda6.C: New test.
Reviewed-by: Jason Merrill <jason@redhat.com>
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/114303] [11/12/13 Regression] ICE with constexpr if and accessing captures across nested generic lambdas
2024-03-11 11:07 [Bug c++/114303] New: ICE with constexpr if and static_assert accessing captures across nested generic lambdas benbarsdell at gmail dot com
` (5 preceding siblings ...)
2024-04-11 14:17 ` cvs-commit at gcc dot gnu.org
@ 2024-04-12 20:04 ` ppalka at gcc dot gnu.org
2024-05-14 2:58 ` cvs-commit at gcc dot gnu.org
7 siblings, 0 replies; 9+ messages in thread
From: ppalka at gcc dot gnu.org @ 2024-04-12 20:04 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114303
Patrick Palka <ppalka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|[11/12/13/14 Regression] |[11/12/13 Regression] ICE
|ICE with constexpr if and |with constexpr if and
|accessing captures across |accessing captures across
|nested generic lambdas |nested generic lambdas
--- Comment #6 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Fixed for GCC 14 so far
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/114303] [11/12/13 Regression] ICE with constexpr if and accessing captures across nested generic lambdas
2024-03-11 11:07 [Bug c++/114303] New: ICE with constexpr if and static_assert accessing captures across nested generic lambdas benbarsdell at gmail dot com
` (6 preceding siblings ...)
2024-04-12 20:04 ` [Bug c++/114303] [11/12/13 " ppalka at gcc dot gnu.org
@ 2024-05-14 2:58 ` cvs-commit at gcc dot gnu.org
7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-05-14 2:58 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114303
--- Comment #7 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-13 branch has been updated by Patrick Palka
<ppalka@gcc.gnu.org>:
https://gcc.gnu.org/g:47cac09307874ff1d640392e3d986453f34f7bcb
commit r13-8767-g47cac09307874ff1d640392e3d986453f34f7bcb
Author: Patrick Palka <ppalka@redhat.com>
Date: Thu Apr 11 10:16:41 2024 -0400
c++: build_extra_args recapturing local specs [PR114303]
r13-6452-g341e6cd8d603a3 made build_extra_args walk evaluated contexts
first so that we prefer processing a local specialization in an evaluated
context even if its first use is in an unevaluated context. But this
means we need to avoid walking a tree that already has extra args/specs
saved because the list of saved specs appears to be an evaluated
context which we'll now walk first. It seems then that we should be
calculating the saved specs from scratch each time, rather than
potentially walking the saved specs list from an earlier partial
instantiation when calling build_extra_args a second time around.
PR c++/114303
gcc/cp/ChangeLog:
* constraint.cc (tsubst_requires_expr): Clear
REQUIRES_EXPR_EXTRA_ARGS before calling build_extra_args.
* pt.cc (tree_extra_args): Define.
(extract_locals_r): Assert *_EXTRA_ARGS is empty.
(tsubst_stmt) <case IF_STMT>: Clear IF_SCOPE on the new
IF_STMT. Call build_extra_args on the new IF_STMT instead
of t which might already have IF_STMT_EXTRA_ARGS.
gcc/testsuite/ChangeLog:
* g++.dg/cpp1z/constexpr-if-lambda6.C: New test.
Reviewed-by: Jason Merrill <jason@redhat.com>
(cherry picked from commit b262b17636e47ae969a74f16e86ccb00678d5e88)
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2024-05-14 2:58 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-11 11:07 [Bug c++/114303] New: ICE with constexpr if and static_assert accessing captures across nested generic lambdas benbarsdell at gmail dot com
2024-03-11 12:46 ` [Bug c++/114303] [11/12/13/14 Regression] " pinskia at gcc dot gnu.org
2024-03-11 12:48 ` [Bug c++/114303] [11/12/13/14 Regression] ICE with constexpr if and " pinskia at gcc dot gnu.org
2024-03-11 14:43 ` ppalka at gcc dot gnu.org
2024-03-15 15:01 ` law at gcc dot gnu.org
2024-03-25 12:52 ` rguenth at gcc dot gnu.org
2024-04-11 14:17 ` cvs-commit at gcc dot gnu.org
2024-04-12 20:04 ` [Bug c++/114303] [11/12/13 " ppalka at gcc dot gnu.org
2024-05-14 2:58 ` cvs-commit at gcc dot gnu.org
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).