public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
* [Bug c++/114901] New: GCC internal_error on CTAD alias @ 2024-04-30 20:20 hokein.wu at gmail dot com 2024-04-30 20:35 ` [Bug c++/114901] " mpolacek at gcc dot gnu.org ` (6 more replies) 0 siblings, 7 replies; 8+ messages in thread From: hokein.wu at gmail dot com @ 2024-04-30 20:20 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114901 Bug ID: 114901 Summary: GCC internal_error on CTAD alias Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: hokein.wu at gmail dot com Target Milestone: --- GCC (trunk) crashes on the following code: https://godbolt.org/z/43Tqf4qs9 ``` template <class D> constexpr bool C = sizeof(D); template <typename U> struct T { template<typename V, typename N> struct Foo { Foo(V, N); }; template<typename X, typename N> requires (C<N>) // removes the require-clause will make the crash disappear Foo(X, N) -> Foo<X, N>; template <typename Y, typename Y2, int N = sizeof(Y2)> using AFoo = Foo<decltype(N), Y2>; }; T<double>::AFoo s{1, 2}; ``` ^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/114901] GCC internal_error on CTAD alias 2024-04-30 20:20 [Bug c++/114901] New: GCC internal_error on CTAD alias hokein.wu at gmail dot com @ 2024-04-30 20:35 ` mpolacek at gcc dot gnu.org 2024-04-30 20:38 ` mpolacek at gcc dot gnu.org ` (5 subsequent siblings) 6 siblings, 0 replies; 8+ messages in thread From: mpolacek at gcc dot gnu.org @ 2024-04-30 20:35 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114901 Marek Polacek <mpolacek at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |mpolacek at gcc dot gnu.org Status|UNCONFIRMED |NEW Last reconfirmed| |2024-04-30 Ever confirmed|0 |1 --- Comment #1 from Marek Polacek <mpolacek at gcc dot gnu.org> --- Confirmed. $ ./cc1plus -quiet 114901.C -std=c++20 114901.C: In static member function ‘static T<double>::Foo(int, Y2)-> Foo<int, Y2> requires __is_deducible (T<double>::AFoo, T<double>::Foo<int, Y2>)’: 114901.C:21:23: internal compiler error: in keep_template_parm, at cp/pt.cc:10933 21 | T<double>::AFoo s{1, 2}; | ^ 0x10dffa0 keep_template_parm /home/mpolacek/src/gcc/gcc/cp/pt.cc:10933 0x10df925 for_each_template_parm_r /home/mpolacek/src/gcc/gcc/cp/pt.cc:10740 0x1ec3aef 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*> >*)) /home/mpolacek/src/gcc/gcc/tree.cc:11429 0x10dfc15 for_each_template_parm /home/mpolacek/src/gcc/gcc/cp/pt.cc:10843 0x10e0362 any_template_parm_r /home/mpolacek/src/gcc/gcc/cp/pt.cc:10975 0x10dec7e for_each_template_parm_r /home/mpolacek/src/gcc/gcc/cp/pt.cc:10632 0x1ec3aef 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*> >*)) /home/mpolacek/src/gcc/gcc/tree.cc:11429 0x10dfc15 for_each_template_parm /home/mpolacek/src/gcc/gcc/cp/pt.cc:10843 0x10e07aa find_template_parameter_info::find_in(tree_node*) /home/mpolacek/src/gcc/gcc/cp/pt.cc:11023 0x10e0a22 find_template_parameters(tree_node*, tree_node*) /home/mpolacek/src/gcc/gcc/cp/pt.cc:11075 0xe2a236 build_parameter_mapping /home/mpolacek/src/gcc/gcc/cp/constraint.cc:594 0xe2aa02 normalize_atom /home/mpolacek/src/gcc/gcc/cp/constraint.cc:819 0xe2ad29 normalize_expression /home/mpolacek/src/gcc/gcc/cp/constraint.cc:886 0xe2a4c9 normalize_logical_operation /home/mpolacek/src/gcc/gcc/cp/constraint.cc:692 0xe2acb2 normalize_expression /home/mpolacek/src/gcc/gcc/cp/constraint.cc:882 0xe2ad82 get_normalized_constraints /home/mpolacek/src/gcc/gcc/cp/constraint.cc:898 0xe2ae40 get_normalized_constraints_from_info /home/mpolacek/src/gcc/gcc/cp/constraint.cc:914 0xe2b0df get_normalized_constraints_from_decl /home/mpolacek/src/gcc/gcc/cp/constraint.cc:990 0xe33953 satisfy_declaration_constraints /home/mpolacek/src/gcc/gcc/cp/constraint.cc:3378 0xe33a70 constraint_satisfaction_value /home/mpolacek/src/gcc/gcc/cp/constraint.cc:3406 ^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/114901] GCC internal_error on CTAD alias 2024-04-30 20:20 [Bug c++/114901] New: GCC internal_error on CTAD alias hokein.wu at gmail dot com 2024-04-30 20:35 ` [Bug c++/114901] " mpolacek at gcc dot gnu.org @ 2024-04-30 20:38 ` mpolacek at gcc dot gnu.org 2024-04-30 20:38 ` mpolacek at gcc dot gnu.org ` (4 subsequent siblings) 6 siblings, 0 replies; 8+ messages in thread From: mpolacek at gcc dot gnu.org @ 2024-04-30 20:38 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114901 Marek Polacek <mpolacek at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jason at gcc dot gnu.org --- Comment #2 from Marek Polacek <mpolacek at gcc dot gnu.org> --- Started with r13-6555: commit 9e6170098d5e7756e85e880f8f4cb18e885a64fd Author: Jason Merrill <jason@redhat.com> Date: Wed Feb 8 22:06:22 2023 -0800 c++: fix alias CTAD [PR105841] ^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/114901] GCC internal_error on CTAD alias 2024-04-30 20:20 [Bug c++/114901] New: GCC internal_error on CTAD alias hokein.wu at gmail dot com 2024-04-30 20:35 ` [Bug c++/114901] " mpolacek at gcc dot gnu.org 2024-04-30 20:38 ` mpolacek at gcc dot gnu.org @ 2024-04-30 20:38 ` mpolacek at gcc dot gnu.org 2024-05-02 10:56 ` rguenth at gcc dot gnu.org ` (3 subsequent siblings) 6 siblings, 0 replies; 8+ messages in thread From: mpolacek at gcc dot gnu.org @ 2024-04-30 20:38 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114901 --- Comment #3 from Marek Polacek <mpolacek at gcc dot gnu.org> --- Before, it was rejected: 114901.C:21:23: error: class template argument deduction failed: 21 | T<double>::AFoo s{1, 2}; | ^ 114901.C:21:23: error: no matching function for call to ‘Foo(int, int)’ ^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/114901] GCC internal_error on CTAD alias 2024-04-30 20:20 [Bug c++/114901] New: GCC internal_error on CTAD alias hokein.wu at gmail dot com ` (2 preceding siblings ...) 2024-04-30 20:38 ` mpolacek at gcc dot gnu.org @ 2024-05-02 10:56 ` rguenth at gcc dot gnu.org 2024-05-13 13:53 ` cvs-commit at gcc dot gnu.org ` (2 subsequent siblings) 6 siblings, 0 replies; 8+ messages in thread From: rguenth at gcc dot gnu.org @ 2024-05-02 10:56 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114901 Richard Biener <rguenth at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |ice-on-valid-code Version|unknown |13.2.1 --- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> --- I suppose it's valid code? ^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/114901] GCC internal_error on CTAD alias 2024-04-30 20:20 [Bug c++/114901] New: GCC internal_error on CTAD alias hokein.wu at gmail dot com ` (3 preceding siblings ...) 2024-05-02 10:56 ` rguenth at gcc dot gnu.org @ 2024-05-13 13:53 ` cvs-commit at gcc dot gnu.org 2024-05-13 15:39 ` cvs-commit at gcc dot gnu.org 2024-05-13 15:40 ` ppalka at gcc dot gnu.org 6 siblings, 0 replies; 8+ messages in thread From: cvs-commit at gcc dot gnu.org @ 2024-05-13 13:53 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114901 --- 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:6d31a370e26eeb950c326332633b3e8e84b6630b commit r15-434-g6d31a370e26eeb950c326332633b3e8e84b6630b Author: Patrick Palka <ppalka@redhat.com> Date: Mon May 13 09:53:40 2024 -0400 c++: nested aggregate/alias CTAD fixes [PR114974, PR114901, PR114903] During maybe_aggr_guide with a nested class template and paren init, like with list init we need to consider the generic template type rather than the partially instantiated type since partial instantiations don't have (partially instantiated) TYPE_FIELDS. In turn we need to partially substitute PARMs in the paren init case as well. As a drive-by improvement it seems better to use outer_template_args instead of DECL_TI_ARGS during this partial substitution so that we lower instead of substitute the innermost template parameters, which is generally more robust. And during alias_ctad_tweaks with a nested class template, even though the guides may be already partially instantiated we still need to substitute the outermost arguments into its constraints. PR c++/114974 PR c++/114901 PR c++/114903 gcc/cp/ChangeLog: * pt.cc (maybe_aggr_guide): Fix obtaining TYPE_FIELDS in the paren init case. Hoist out partial substitution logic to apply to the paren init case as well. (alias_ctad_tweaks): Substitute outer template arguments into a guide's constraints. gcc/testsuite/ChangeLog: * g++.dg/cpp2a/class-deduction-aggr14.C: New test. * g++.dg/cpp2a/class-deduction-alias20.C: New test. * g++.dg/cpp2a/class-deduction-alias21.C: New test. Reviewed-by: Jason Merrill <jason@redhat.com> ^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/114901] GCC internal_error on CTAD alias 2024-04-30 20:20 [Bug c++/114901] New: GCC internal_error on CTAD alias hokein.wu at gmail dot com ` (4 preceding siblings ...) 2024-05-13 13:53 ` cvs-commit at gcc dot gnu.org @ 2024-05-13 15:39 ` cvs-commit at gcc dot gnu.org 2024-05-13 15:40 ` ppalka at gcc dot gnu.org 6 siblings, 0 replies; 8+ messages in thread From: cvs-commit at gcc dot gnu.org @ 2024-05-13 15:39 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114901 --- Comment #6 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The releases/gcc-14 branch has been updated by Patrick Palka <ppalka@gcc.gnu.org>: https://gcc.gnu.org/g:57cd8665fea4c339369a43be017583621aa82fed commit r14-10201-g57cd8665fea4c339369a43be017583621aa82fed Author: Patrick Palka <ppalka@redhat.com> Date: Mon May 13 09:53:40 2024 -0400 c++: nested aggregate/alias CTAD fixes [PR114974, PR114901, PR114903] During maybe_aggr_guide with a nested class template and paren init, like with list init we need to consider the generic template type rather than the partially instantiated type since partial instantiations don't have (partially instantiated) TYPE_FIELDS. In turn we need to partially substitute PARMs in the paren init case as well. As a drive-by improvement it seems better to use outer_template_args instead of DECL_TI_ARGS during this partial substitution so that we lower instead of substitute the innermost template parameters, which is generally more robust. And during alias_ctad_tweaks with a nested class template, even though the guides may be already partially instantiated we still need to substitute the outermost arguments into its constraints. PR c++/114974 PR c++/114901 PR c++/114903 gcc/cp/ChangeLog: * pt.cc (maybe_aggr_guide): Fix obtaining TYPE_FIELDS in the paren init case. Hoist out partial substitution logic to apply to the paren init case as well. (alias_ctad_tweaks): Substitute outer template arguments into a guide's constraints. gcc/testsuite/ChangeLog: * g++.dg/cpp2a/class-deduction-aggr14.C: New test. * g++.dg/cpp2a/class-deduction-alias20.C: New test. * g++.dg/cpp2a/class-deduction-alias21.C: New test. Reviewed-by: Jason Merrill <jason@redhat.com> (cherry picked from commit 6d31a370e26eeb950c326332633b3e8e84b6630b) ^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/114901] GCC internal_error on CTAD alias 2024-04-30 20:20 [Bug c++/114901] New: GCC internal_error on CTAD alias hokein.wu at gmail dot com ` (5 preceding siblings ...) 2024-05-13 15:39 ` cvs-commit at gcc dot gnu.org @ 2024-05-13 15:40 ` ppalka at gcc dot gnu.org 6 siblings, 0 replies; 8+ messages in thread From: ppalka at gcc dot gnu.org @ 2024-05-13 15:40 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114901 Patrick Palka <ppalka at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Target Milestone|--- |14.2 CC| |ppalka at gcc dot gnu.org Assignee|unassigned at gcc dot gnu.org |ppalka at gcc dot gnu.org Resolution|--- |FIXED Status|NEW |RESOLVED --- Comment #7 from Patrick Palka <ppalka at gcc dot gnu.org> --- Fixed for GCC 14.2 ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2024-05-13 15:40 UTC | newest] Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2024-04-30 20:20 [Bug c++/114901] New: GCC internal_error on CTAD alias hokein.wu at gmail dot com 2024-04-30 20:35 ` [Bug c++/114901] " mpolacek at gcc dot gnu.org 2024-04-30 20:38 ` mpolacek at gcc dot gnu.org 2024-04-30 20:38 ` mpolacek at gcc dot gnu.org 2024-05-02 10:56 ` rguenth at gcc dot gnu.org 2024-05-13 13:53 ` cvs-commit at gcc dot gnu.org 2024-05-13 15:39 ` cvs-commit at gcc dot gnu.org 2024-05-13 15:40 ` 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).