Reduced example: template <class T> struct C { constexpr C(int) {} }; explicit C(int) -> C<int>; template <C c> struct X { }; X<1> x; This should fail to compile, because the deduction guide is explicit and so should not be a candidate, but gcc accepts this example. gcc does correctly reject: C y = 1; Which is the same kind of thing.
The master branch has been updated by Patrick Palka <ppalka@gcc.gnu.org>: https://gcc.gnu.org/g:a6b3db3e8625a3cba1240f0b5e1a29bd6c68b8ca commit r12-2990-ga6b3db3e8625a3cba1240f0b5e1a29bd6c68b8ca Author: Patrick Palka <ppalka@redhat.com> Date: Wed Aug 18 08:37:42 2021 -0400 c++: ignore explicit dguides during NTTP CTAD [PR101883] Since (template) argument passing is a copy-initialization context, we mustn't consider explicit deduction guides when deducing a CTAD placeholder type of an NTTP. PR c++/101883 gcc/cp/ChangeLog: * pt.c (convert_template_argument): Pass LOOKUP_IMPLICIT to do_auto_deduction. gcc/testsuite/ChangeLog: * g++.dg/cpp2a/nontype-class49.C: New test.
The releases/gcc-11 branch has been updated by Patrick Palka <ppalka@gcc.gnu.org>: https://gcc.gnu.org/g:52dd840c5eba25ef54dee3f1c78f371032a7c051 commit r11-9078-g52dd840c5eba25ef54dee3f1c78f371032a7c051 Author: Patrick Palka <ppalka@redhat.com> Date: Wed Aug 18 08:37:42 2021 -0400 c++: ignore explicit dguides during NTTP CTAD [PR101883] Since (template) argument passing is a copy-initialization context, we mustn't consider explicit deduction guides when deducing a CTAD placeholder type of an NTTP. PR c++/101883 gcc/cp/ChangeLog: * pt.c (convert_template_argument): Pass LOOKUP_IMPLICIT to do_auto_deduction. gcc/testsuite/ChangeLog: * g++.dg/cpp2a/nontype-class49.C: New test. (cherry picked from commit a6b3db3e8625a3cba1240f0b5e1a29bd6c68b8ca)
Fixed for GCC 11.3 and 12.