[Bug debug/84318] New: attribute deprecated on function templates different than class templates

msebor at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Fri Feb 9 23:45:00 GMT 2018


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

            Bug ID: 84318
           Summary: attribute deprecated on function templates different
                    than class templates
           Product: gcc
           Version: 8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: debug
          Assignee: unassigned at gcc dot gnu.org
          Reporter: msebor at gcc dot gnu.org
  Target Milestone: ---

When a primary class template is declared deprecated, GCC will issue
-Wdeprecated-declarations for declarations of explicit specialization of the
template.  However, when a primary function template is declared deprecated,
GCC accepts declarations of its explicit specializations with no warning.  Both
kinds of declarations should be treated the same (and I'd say both should
trigger a warning).

$ cat t.C && gcc -S -Wall t.C
template <class T>
struct __attribute__ ((deprecated ("class")))
S { };

template <>
struct S<void> { };   // -Wdeprecated-declarations (good)


template <class T>
void __attribute__ ((deprecated ("function")))
foo ();

template <>
void foo<void> ();   // missing -Wdeprecated-declarations (bug)
t.C:6:8: warning: ‘template<class T> struct S’ is deprecated
[-Wdeprecated-declarations]
 struct S<void> { };
        ^
t.C:3:1: note: declared here
 S { };


More information about the Gcc-bugs mailing list