public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/103346] New: ICE on template specialization via alias template with a non-type parameter pack, and fold expression on lambda calls
@ 2021-11-21 11:56 ap.vanzanten at gmail dot com
2021-11-22 9:06 ` [Bug c++/103346] " marxin at gcc dot gnu.org
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: ap.vanzanten at gmail dot com @ 2021-11-21 11:56 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103346
Bug ID: 103346
Summary: ICE on template specialization via alias template with
a non-type parameter pack, and fold expression on
lambda calls
Product: gcc
Version: 11.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: ap.vanzanten at gmail dot com
Target Milestone: ---
Command: g++ -std=c++20 <code file>
Code:
----
struct Item {};
template <typename T, T... ts>
struct Sequence;
template <Item... items>
using ItemSequence = Sequence<Item, items...>;
template <Item... items>
constexpr auto f() {
constexpr auto l = [](Item item) { return item; };
return ItemSequence<l(items)...>{};
}
----
Output:
----
<source>: In substitution of 'template<Item ...items> using ItemSequence =
Sequence<Item, (const Item)items ...> [with Item ...items = {f::l((const
Item)items)...}]':
<source>:12:34: required from here
<source>:7:37: internal compiler error: Segmentation fault
7 | using ItemSequence = Sequence<Item, items...>;
| ^~~~~
0x1786229 internal_error(char const*, ...)
???:0
0xfa6740 strip_array_types(tree_node*)
???:0
0x82f438 cp_type_quals(tree_node const*)
???:0
0x7e8a1b tsubst_pack_expansion(tree_node*, tree_node*, int, tree_node*)
???:0
0x7ef14a tsubst_template_args(tree_node*, tree_node*, int, tree_node*)
???:0
0x7ef72c tsubst_argument_pack(tree_node*, tree_node*, int, tree_node*)
???:0
0x7ef12c tsubst_template_args(tree_node*, tree_node*, int, tree_node*)
???:0
0x7dd7cc tsubst(tree_node*, tree_node*, int, tree_node*)
???:0
0x7dd8a7 tsubst(tree_node*, tree_node*, int, tree_node*)
???:0
0x7f40b2 instantiate_template(tree_node*, tree_node*, int)
???:0
0x7dde4d tsubst(tree_node*, tree_node*, int, tree_node*)
???:0
0x7e6702 lookup_template_class(tree_node*, tree_node*, tree_node*, tree_node*,
int, int)
???:0
0x80a52d finish_template_type(tree_node*, tree_node*, int)
???:0
0x7c47db c_parse_file()
???:0
0x896762 c_common_parse_file()
???:0
Please submit a full bug report,
...
----
Note the issue is not present when moving the lambda 'l' out of the function
'f' (into global scope), or when removing the 'ItemSequence' alias, and simply
using 'Sequence<Item, items...>' directly.
See also https://godbolt.org/z/Yqnnod4W6 for a live example.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/103346] ICE on template specialization via alias template with a non-type parameter pack, and fold expression on lambda calls
2021-11-21 11:56 [Bug c++/103346] New: ICE on template specialization via alias template with a non-type parameter pack, and fold expression on lambda calls ap.vanzanten at gmail dot com
@ 2021-11-22 9:06 ` marxin at gcc dot gnu.org
2022-12-20 16:09 ` cvs-commit at gcc dot gnu.org
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: marxin at gcc dot gnu.org @ 2021-11-22 9:06 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103346
Martin Liška <marxin at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Last reconfirmed| |2021-11-22
Ever confirmed|0 |1
Status|UNCONFIRMED |NEW
Keywords| |rejects-valid
CC| |jason at gcc dot gnu.org,
| |marxin at gcc dot gnu.org
--- Comment #1 from Martin Liška <marxin at gcc dot gnu.org> ---
Confirmed, started with r9-3836-g4be5c72cf3ea3ee9, it was rejected before the
revision.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/103346] ICE on template specialization via alias template with a non-type parameter pack, and fold expression on lambda calls
2021-11-21 11:56 [Bug c++/103346] New: ICE on template specialization via alias template with a non-type parameter pack, and fold expression on lambda calls ap.vanzanten at gmail dot com
2021-11-22 9:06 ` [Bug c++/103346] " marxin at gcc dot gnu.org
@ 2022-12-20 16:09 ` cvs-commit at gcc dot gnu.org
2022-12-20 16:12 ` ppalka at gcc dot gnu.org
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-12-20 16:09 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103346
--- Comment #2 from CVS 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:49b6b7ac3314843466395c4a194aa178c80e64f5
commit r13-4807-g49b6b7ac3314843466395c4a194aa178c80e64f5
Author: Patrick Palka <ppalka@redhat.com>
Date: Tue Dec 20 11:09:11 2022 -0500
c++: NTTP object wrapper substitution fixes [PR103346, ...]
This patch fixes some issues with substitution into a C++20 template
parameter object wrapper:
* The first testcase demonstrates a situation where the same_type_p
assert in relevant case of tsubst_copy doesn't hold, because (partial)
substitution of {int,} into the wrapper's TREE_TYPE yields A<int> but
substitution into the underlying TEMPLATE_PARM_INDEX is a nop due to
tsubst's level==1/tf_partial early exit tests, hence TREE_TYPE in the
latter case remains A<T>. So this patch just gets rid of the assert;
the type mismatch doesn't seem to be a problem in practice.
* In the second testcase, dependent substitution into the underlying
TEMPLATE_PARM_INDEX yields a CALL_EXPR with empty TREE_TYPE, which
tsubst_copy doesn't expect. This patch fixes this by handling empty
TREE_TYPE the same way as a non-const TREE_TYPE. Moreover, after
this substitution we're left with a VIEW_CONVERT_EXPR wrapping a
CALL_EXPR instead of a TEMPLATE_PARM_INDEX, which during the subsequent
non-dependent substitution tsubst_copy doesn't expect either. So
this patch also relaxes tsubst_copy to accept such VIEW_CONVERT_EXPR
too.
* In the third testcase, we end up never resolving the call to
f.modify() because tsubst_copy doesn't do overload resolution.
This patch fixes this by moving the handling of these
VIEW_CONVERT_EXPR wrappers from tsubst_copy to tsubst_copy_and_build.
For good measure tsubst_copy_and_build should also handle
REF_PARENTHESIZED_P wrappers instead of delegating to tsubst_copy.
PR c++/103346
PR c++/104278
PR c++/102553
gcc/cp/ChangeLog:
* pt.cc (tsubst_copy) <case VIEW_CONVERT_EXPR>: Move the
handling of C++20 template parameter object wrappers to ...
(tsubst_copy_and_build) <case VIEW_CONVERT_EXPR>: ... here.
Accept non-TEMPLATE_PARM_INDEX inner operand. Handle empty
TREE_TYPE on substituted inner operand. Remove same_type_p
assert. Also handle REF_PARENTHESIZED_P VIEW_CONVERT_EXPRs.
gcc/testsuite/ChangeLog:
* g++.dg/cpp2a/nontype-class52a.C: New test.
* g++.dg/cpp2a/nontype-class53.C: New test.
* g++.dg/cpp2a/nontype-class54.C: New test.
* g++.dg/cpp2a/nontype-class55.C: New test.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/103346] ICE on template specialization via alias template with a non-type parameter pack, and fold expression on lambda calls
2021-11-21 11:56 [Bug c++/103346] New: ICE on template specialization via alias template with a non-type parameter pack, and fold expression on lambda calls ap.vanzanten at gmail dot com
2021-11-22 9:06 ` [Bug c++/103346] " marxin at gcc dot gnu.org
2022-12-20 16:09 ` cvs-commit at gcc dot gnu.org
@ 2022-12-20 16:12 ` ppalka at gcc dot gnu.org
2023-08-03 14:04 ` ppalka at gcc dot gnu.org
2023-11-16 15:38 ` ppalka at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: ppalka at gcc dot gnu.org @ 2022-12-20 16:12 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103346
Patrick Palka <ppalka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Known to work| |13.0
CC| |ppalka at gcc dot gnu.org
Assignee|unassigned at gcc dot gnu.org |ppalka at gcc dot gnu.org
Status|NEW |ASSIGNED
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/103346] ICE on template specialization via alias template with a non-type parameter pack, and fold expression on lambda calls
2021-11-21 11:56 [Bug c++/103346] New: ICE on template specialization via alias template with a non-type parameter pack, and fold expression on lambda calls ap.vanzanten at gmail dot com
` (2 preceding siblings ...)
2022-12-20 16:12 ` ppalka at gcc dot gnu.org
@ 2023-08-03 14:04 ` ppalka at gcc dot gnu.org
2023-11-16 15:38 ` ppalka at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: ppalka at gcc dot gnu.org @ 2023-08-03 14:04 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103346
Patrick Palka <ppalka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution|--- |FIXED
Target Milestone|--- |13.0
--- Comment #3 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Fixed for GCC 13
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/103346] ICE on template specialization via alias template with a non-type parameter pack, and fold expression on lambda calls
2021-11-21 11:56 [Bug c++/103346] New: ICE on template specialization via alias template with a non-type parameter pack, and fold expression on lambda calls ap.vanzanten at gmail dot com
` (3 preceding siblings ...)
2023-08-03 14:04 ` ppalka at gcc dot gnu.org
@ 2023-11-16 15:38 ` ppalka at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: ppalka at gcc dot gnu.org @ 2023-11-16 15:38 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103346
Patrick Palka <ppalka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |iDingDong at outlook dot com
--- Comment #4 from Patrick Palka <ppalka at gcc dot gnu.org> ---
*** Bug 102470 has been marked as a duplicate of this bug. ***
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2023-11-16 15:38 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-21 11:56 [Bug c++/103346] New: ICE on template specialization via alias template with a non-type parameter pack, and fold expression on lambda calls ap.vanzanten at gmail dot com
2021-11-22 9:06 ` [Bug c++/103346] " marxin at gcc dot gnu.org
2022-12-20 16:09 ` cvs-commit at gcc dot gnu.org
2022-12-20 16:12 ` ppalka at gcc dot gnu.org
2023-08-03 14:04 ` ppalka at gcc dot gnu.org
2023-11-16 15:38 ` ppalka 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).