From: Patrick Palka Date: Thu, 10 Apr 2025 19:49:12 +0000 (-0400) Subject: c++: alias_ctad_tweaks ICE w/ inherited CTAD [PR119687] X-Git-Tag: basepoints/gcc-16~186 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=493974aa0ad8b94dbeb61f00d2acc57c94fd4809;p=thirdparty%2Fgcc.git c++: alias_ctad_tweaks ICE w/ inherited CTAD [PR119687] With inherited CTAD the set of guides may be a two-dimensional overload set (i.e. OVERLOADs of OVERLOADs) so alias_ctad_tweaks (which also does the inherited CTAD transformation) needs to use the 2D-aware lkp_iterator instead of ovl_iterator, or better yet use the more idiomatic lkp_range. PR c++/119687 gcc/cp/ChangeLog: * pt.cc (alias_ctad_tweaks): Use lkp_range / lkp_iterator instead of ovl_iterator. gcc/testsuite/ChangeLog: * g++.dg/cpp23/class-deduction-inherited8.C: New test. Reviewed-by: Jason Merill --- diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc index 63c2ec0c59b..805b274069b 100644 --- a/gcc/cp/pt.cc +++ b/gcc/cp/pt.cc @@ -30936,9 +30936,8 @@ alias_ctad_tweaks (tree tmpl, tree uguides) tree aguides = NULL_TREE; tree atparms = INNERMOST_TEMPLATE_PARMS (fullatparms); unsigned natparms = TREE_VEC_LENGTH (atparms); - for (ovl_iterator iter (uguides); iter; ++iter) + for (tree f : lkp_range (uguides)) { - tree f = *iter; tree in_decl = f; location_t loc = DECL_SOURCE_LOCATION (f); tree ret = TREE_TYPE (TREE_TYPE (f)); diff --git a/gcc/testsuite/g++.dg/cpp23/class-deduction-inherited8.C b/gcc/testsuite/g++.dg/cpp23/class-deduction-inherited8.C new file mode 100644 index 00000000000..4494c701c35 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp23/class-deduction-inherited8.C @@ -0,0 +1,21 @@ +// PR c++/119687 +// { dg-do compile { target c++17 } } + +template class QFlagsStorage{}; + +template struct QFlagsStorageHelper : QFlagsStorage { + using QFlagsStorage::QFlagsStorage; + +public: + QFlagsStorageHelper(Enum); +}; + +template struct QFlags : public QFlagsStorageHelper { + using Base = QFlagsStorageHelper; + using Base::Base; + QFlags(Enum); +}; + +void f(int flag) { + QFlags{int{}}; +}