public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/103672] New: using with template<template<class...> class> causes internal compiler error
@ 2021-12-12 18:51 turtlefight at ymail dot com
2021-12-13 11:59 ` [Bug c++/103672] [10/11/12 Regression] " redi at gcc dot gnu.org
` (7 more replies)
0 siblings, 8 replies; 9+ messages in thread
From: turtlefight at ymail dot com @ 2021-12-12 18:51 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103672
Bug ID: 103672
Summary: using with template<template<class...> class> causes
internal compiler error
Product: gcc
Version: 11.2.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: turtlefight at ymail dot com
Target Milestone: ---
The following example results in an internal compiler error.
It does compile fine with clang and msvc.
Example Code:
#include <functional>
#include <memory>
template<class T>
struct unique {
auto operator()(auto&&... args) {
return std::make_unique<T>(std::forward<decltype(args)>(args)...);
}
};
template<template<class...> class T, class... Args>
using deduced_type = decltype(T{std::declval<Args>()...});
template<template<class> class F, template<class...> class T, class... Args>
auto make(Args&&... args) {
return F<deduced_type<T, Args...>>{}(std::forward<Args>(args)...);
}
template<class A, class B>
struct Foo { Foo(A,B) {} };
int main(){
auto foo_unique = make<unique, Foo>(1, 2);
}
Full Error Message:
<source>: In instantiation of 'auto make(Args&& ...) [with F = unique; T = Foo;
Args = {int, int}]':
<source>:24:40: required from here
<source>:16:41: internal compiler error: in tsubst, at cp/pt.c:15632
16 | return F<deduced_type<T, Args...>>{}(std::forward<Args>(args)...);
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
0x21004e9 internal_error(char const*, ...)
???:0
0x7e96eb fancy_abort(char const*, int, char const*)
???:0
0xa5fde7 tsubst(tree_node*, tree_node*, int, tree_node*)
???:0
0xa5d3af tsubst(tree_node*, tree_node*, int, tree_node*)
???:0
0xa89b76 tsubst_template_args(tree_node*, tree_node*, int, tree_node*)
???:0
0xa5d954 tsubst(tree_node*, tree_node*, int, tree_node*)
???:0
0xa5eb8d tsubst(tree_node*, tree_node*, int, tree_node*)
???:0
0xa63a47 instantiate_decl(tree_node*, bool, bool)
???:0
0x904ebe maybe_instantiate_decl(tree_node*)
???:0
0x906980 mark_used(tree_node*, int)
???:0
0x819197 build_new_function_call(tree_node*, vec<tree_node*, va_gc,
vl_embed>**, int)
???:0
0xaca89c finish_call_expr(tree_node*, vec<tree_node*, va_gc, vl_embed>**, bool,
bool, int)
???:0
0xa29b8d c_parse_file()
???:0
0xbb6bb2 c_common_parse_file()
???:0
Godbolt Example: https://godbolt.org/z/rd4PdYrq8
What's interesting is that the code compiles without problems if a using
declaration is not used, e.g.:
template<template<class> class F, template<class...> class T, class... Args>
auto make(Args&&... args) {
return
F<decltype(T{std::declval<Args>()...})>{}(std::forward<Args>(args)...);
}
Godbolt Example: https://godbolt.org/z/Pd3Mjs8rG
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/103672] [10/11/12 Regression] using with template<template<class...> class> causes internal compiler error
2021-12-12 18:51 [Bug c++/103672] New: using with template<template<class...> class> causes internal compiler error turtlefight at ymail dot com
@ 2021-12-13 11:59 ` redi at gcc dot gnu.org
2022-01-04 9:47 ` rguenth at gcc dot gnu.org
` (6 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: redi at gcc dot gnu.org @ 2021-12-13 11:59 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103672
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Last reconfirmed| |2021-12-13
Keywords| |ice-on-valid-code
Known to work| |10.2.0, 9.4.0
CC| |ppalka at gcc dot gnu.org
Status|UNCONFIRMED |NEW
Known to fail| |10.3.0, 11.1.0, 12.0
Summary|using with |[10/11/12 Regression] using
|template<template<class...> |with
|class> causes internal |template<template<class...>
|compiler error |class> causes internal
| |compiler error
Ever confirmed|0 |1
--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
This started to ICE on trunk with r11-6614
c++: Fix ICE with CTAD in concept [PR98611]
It was also backported to 10.3 as r10-9635
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/103672] [10/11/12 Regression] using with template<template<class...> class> causes internal compiler error
2021-12-12 18:51 [Bug c++/103672] New: using with template<template<class...> class> causes internal compiler error turtlefight at ymail dot com
2021-12-13 11:59 ` [Bug c++/103672] [10/11/12 Regression] " redi at gcc dot gnu.org
@ 2022-01-04 9:47 ` rguenth at gcc dot gnu.org
2022-01-13 15:28 ` ppalka at gcc dot gnu.org
` (5 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-01-04 9:47 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103672
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Priority|P3 |P2
Target Milestone|--- |10.4
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/103672] [10/11/12 Regression] using with template<template<class...> class> causes internal compiler error
2021-12-12 18:51 [Bug c++/103672] New: using with template<template<class...> class> causes internal compiler error turtlefight at ymail dot com
2021-12-13 11:59 ` [Bug c++/103672] [10/11/12 Regression] " redi at gcc dot gnu.org
2022-01-04 9:47 ` rguenth at gcc dot gnu.org
@ 2022-01-13 15:28 ` ppalka at gcc dot gnu.org
2022-01-20 14:26 ` cvs-commit at gcc dot gnu.org
` (4 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: ppalka at gcc dot gnu.org @ 2022-01-13 15:28 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103672
Patrick Palka <ppalka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
See Also| |https://gcc.gnu.org/bugzill
| |a/show_bug.cgi?id=91911
--- Comment #2 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Closely related to PR91911 due to the use of CTAD + alias template
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/103672] [10/11/12 Regression] using with template<template<class...> class> causes internal compiler error
2021-12-12 18:51 [Bug c++/103672] New: using with template<template<class...> class> causes internal compiler error turtlefight at ymail dot com
` (2 preceding siblings ...)
2022-01-13 15:28 ` ppalka at gcc dot gnu.org
@ 2022-01-20 14:26 ` cvs-commit at gcc dot gnu.org
2022-01-20 14:30 ` [Bug c++/103672] [10/11 " ppalka at gcc dot gnu.org
` (3 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-01-20 14:26 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103672
--- Comment #3 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:09845ad7569bac27c3a1dc7b410d9df764d2ca06
commit r12-6773-g09845ad7569bac27c3a1dc7b410d9df764d2ca06
Author: Patrick Palka <ppalka@redhat.com>
Date: Thu Jan 20 09:25:49 2022 -0500
c++: CTAD inside alias template [PR91911, PR103672]
In the first testcase below, when processing the alias template
ConstSpanType, transparency of alias template specializations means we
replace SpanType<T> with its instantiated definition. But this
instantiation lowers the level of the CTAD placeholder for span{T()} from
2 to 1, and so the later instantiation of ConstSpanType<int> erroneously
substitutes this CTAD placeholder with the template argument at level 1
index 0, i.e. with int, before we get a chance to perform the CTAD.
Although we represent CTAD placeholders as template parameters, we never
actually want to replace them via tsubst. So this patch adjusts tsubst
to handle CTAD placeholders by simply substituting the template and
returning a new CTAD placeholder. Moreover, this means that the level
of a CTAD placeholder doesn't matter, so we may as well give them all
the same level. This patch gives them the special level 0.
The change in tsubst_decl removes a likely dead !CHECKING_P safeguard
added in 2017, which would otherwise now get triggered for variables
with CTAD placeholder types (since their level is 0).
PR c++/91911
PR c++/103672
gcc/cp/ChangeLog:
* pt.cc (keep_template_parm): Punt on a level 0 template parm.
(tsubst_decl) <case VAR_DECL>: Remove !CHECKING_P safeguard.
(tsubst) <case TEMPLATE_TYPE_PARM>: Handle CTAD placeholders
specially.
(make_auto_1): Add defaulted 'level' parameter.
(make_template_placeholder): Pass 0 as 'level' to make_auto_1.
gcc/testsuite/ChangeLog:
* g++.dg/cpp1z/class-deduction101.C: New test.
* g++.dg/cpp1z/class-deduction101a.C: New test.
* g++.dg/cpp1z/class-deduction101b.C: New test.
* g++.dg/cpp1z/class-deduction102.C: New test.
* g++.dg/cpp1z/class-deduction102a.C: New test.
* g++.dg/cpp1z/class-deduction102b.C: New test.
* g++.dg/cpp1z/class-deduction103.C: New test.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/103672] [10/11 Regression] using with template<template<class...> class> causes internal compiler error
2021-12-12 18:51 [Bug c++/103672] New: using with template<template<class...> class> causes internal compiler error turtlefight at ymail dot com
` (3 preceding siblings ...)
2022-01-20 14:26 ` cvs-commit at gcc dot gnu.org
@ 2022-01-20 14:30 ` ppalka at gcc dot gnu.org
2022-05-11 17:48 ` ppalka at gcc dot gnu.org
` (2 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: ppalka at gcc dot gnu.org @ 2022-01-20 14:30 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103672
Patrick Palka <ppalka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|[10/11/12 Regression] using |[10/11 Regression] using
|with |with
|template<template<class...> |template<template<class...>
|class> causes internal |class> causes internal
|compiler error |compiler error
--- Comment #4 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Fixed for GCC 12 so far.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/103672] [10/11 Regression] using with template<template<class...> class> causes internal compiler error
2021-12-12 18:51 [Bug c++/103672] New: using with template<template<class...> class> causes internal compiler error turtlefight at ymail dot com
` (4 preceding siblings ...)
2022-01-20 14:30 ` [Bug c++/103672] [10/11 " ppalka at gcc dot gnu.org
@ 2022-05-11 17:48 ` ppalka at gcc dot gnu.org
2022-06-28 10:47 ` jakub at gcc dot gnu.org
2023-05-21 15:12 ` ppalka at gcc dot gnu.org
7 siblings, 0 replies; 9+ messages in thread
From: ppalka at gcc dot gnu.org @ 2022-05-11 17:48 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103672
Patrick Palka <ppalka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |ASSIGNED
Assignee|unassigned at gcc dot gnu.org |ppalka at gcc dot gnu.org
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/103672] [10/11 Regression] using with template<template<class...> class> causes internal compiler error
2021-12-12 18:51 [Bug c++/103672] New: using with template<template<class...> class> causes internal compiler error turtlefight at ymail dot com
` (5 preceding siblings ...)
2022-05-11 17:48 ` ppalka at gcc dot gnu.org
@ 2022-06-28 10:47 ` jakub at gcc dot gnu.org
2023-05-21 15:12 ` ppalka at gcc dot gnu.org
7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu.org @ 2022-06-28 10:47 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103672
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|10.4 |10.5
--- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
GCC 10.4 is being released, retargeting bugs to GCC 10.5.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/103672] [10/11 Regression] using with template<template<class...> class> causes internal compiler error
2021-12-12 18:51 [Bug c++/103672] New: using with template<template<class...> class> causes internal compiler error turtlefight at ymail dot com
` (6 preceding siblings ...)
2022-06-28 10:47 ` jakub at gcc dot gnu.org
@ 2023-05-21 15:12 ` ppalka at gcc dot gnu.org
7 siblings, 0 replies; 9+ messages in thread
From: ppalka at gcc dot gnu.org @ 2023-05-21 15:12 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103672
Patrick Palka <ppalka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Target Milestone|10.5 |12.0
Resolution|--- |FIXED
--- Comment #6 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Fixed for GCC 12+. This doesn't seem suitable for backporting, and never
properly worked before anyway so it's hardly a regression.
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2023-05-21 15:12 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-12 18:51 [Bug c++/103672] New: using with template<template<class...> class> causes internal compiler error turtlefight at ymail dot com
2021-12-13 11:59 ` [Bug c++/103672] [10/11/12 Regression] " redi at gcc dot gnu.org
2022-01-04 9:47 ` rguenth at gcc dot gnu.org
2022-01-13 15:28 ` ppalka at gcc dot gnu.org
2022-01-20 14:26 ` cvs-commit at gcc dot gnu.org
2022-01-20 14:30 ` [Bug c++/103672] [10/11 " ppalka at gcc dot gnu.org
2022-05-11 17:48 ` ppalka at gcc dot gnu.org
2022-06-28 10:47 ` jakub at gcc dot gnu.org
2023-05-21 15:12 ` 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).