https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122958

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org,
                   |                            |ppalka at gcc dot gnu.org

--- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
template <typename S, typename T> struct A { static constexpr bool value =
false; };
template <bool> struct B { using type = void; };

template <class>
class C;

template <class R, class... S>
class C <R (S...)>;

template <class R, class... S, class RC = typename B <A <R,
void>::value>::type>
class C <R (S...)>
{
};

C <void ()> c;

Seems when push_template_decl -> check_default_tmpl_args is called on the first
partial specialization, then is_partial is true, but when it is called on the
template <class R, class... S, class RC = typename B <A <R,
void>::value>::type>
class C <R (S...)>
{
};
one, while CLASSTYPE_TEMPLATE_SPECIALIZATION (TREE_TYPE (decl)) is true,
DECL_IMPLICIT_TYPEDEF_P (decl) is false and so is_partial isn't set and nothing
complains about the default argument on partial specialization.

With
template <class R, class... S>
class C <R (S...)>;
commented out, it is diagnosed:
pr122958.C:11:7: error: default template arguments may not be used in partial
specializations
   11 | class C <R (S...)>
      |       ^~~~~~~~~~~~
pr122958.C:11:7: error: template parameters not deducible in partial
specialization:
pr122958.C:11:7: note:         ‘RC’
pr122958.C:15:13: error: aggregate ‘C<void()> c’ has incomplete type and cannot
be defined
   15 | C <void ()> c;
      |             ^

Reply via email to