[Bug c++/80771] GCC ignores default template argument declaration in the template definition

redi at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Tue May 16 15:28:00 GMT 2017


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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|wrong-code                  |rejects-valid
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2017-05-16
     Ever confirmed|0                           |1

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
template<int> struct enable_if { using type = void; };

struct Foo { };

// This is a template function declaration, where second template argument
declared without a default
template <typename T, typename>
void foo(const Foo &, T);

// This is a template function definition; second template argument now has a
default declared
template <typename T, typename = typename enable_if<1>::type>
void foo(const Foo &, T)
{
}

int main()
{
    foo(Foo{}, 1);
}


More information about the Gcc-bugs mailing list