[Bug c++/60753] New: defining an explicit function template specialization as deleted, following a non-deleted declaration, not diagnosted

filip.roseen at gmail dot com gcc-bugzilla@gcc.gnu.org
Thu Apr 3 23:22:00 GMT 2014


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60753

            Bug ID: 60753
           Summary: defining an explicit function template specialization
                    as deleted, following a non-deleted declaration, not
                    diagnosted
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: filip.roseen at gmail dot com

Created attachment 32537
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=32537&action=edit
testcase.cpp

template<class T> void func (T);

template<> void func<int> (int);
template<> void func<int> (int) = delete;

int main () { }

------------------------------------------------------------------------

`gcc` accepts the above snippet.

------------------------------------------------------------------------

The previous snippet is ill-formed according to [dcl.fct.def.delete]p4:

  > A deleted definition of a function shall be the first declaration
  > of the function or, for an explicit specialization of a function
  > template, the first declaration of that specialization.

------------------------------------------------------------------------

`clang` correctly issues the following diagnostic:

testcase.cpp:4:35: error: deleted definition must be first declaration
template<> void func<int> (int) = delete;
                                  ^
testcase.cpp:3:17: note: previous declaration is here
template<> void func<int> (int);
                ^

------------------------------------------------------------------------



More information about the Gcc-bugs mailing list