This is GCC Bugzilla
This is GCC Bugzilla Version 2.20+
View Bug Activity | Format For Printing | Clone This Bug
In the following example, class "foo" gets a deprecated warning, but a similar class template "goo" does not. Typedefs constructed with foo or goo get an error. What up? struct foo { int i; } __attribute__ ((__deprecated__)); template<typename _Tp> struct goo { int i; } __attribute__ ((__deprecated__)); typedef foo foo_type __attribute__ ((__deprecated__)); typedef goo<int> goo_type __attribute__ ((__deprecated__)); int main() { foo f1; goo<int> f2; foo_type f3; goo_type f4; return 0; } I have a patch to mark the C++0x bits deprecated, but it's not working because of this issue.
*** Bug 33912 has been marked as a duplicate of this bug. ***
I can second that problem for template member functions - in contrast to non-template member functions, where the attribute works. This gives a warning about deprecation as expected: ----------------------------------------------------------------- struct T { } ; struct A { inline void foo(T & ) __attribute__((deprecated)); }; inline void A::foo(T & ) { } void test(T & t) { A a; a.foo(t); } ------------------------------------------------------------- ... while this is not causing a warning as it should: ------------------------------------------------------------- struct A { template <class T> inline void foo(T & ) __attribute__((deprecated)); }; template <class T> inline void A::foo(T & ) { } void test(A & t) { A a; a.foo(t); } -------------------------------------------------------------
Subject: Re: attribute deprecated vs. templates niemayer at isg dot de wrote: > I can second that problem for template member functions - in contrast to > non-template member functions, where the attribute works. This is a parser bug: parsing the member template declaration winds up in cp_parser_init_declarator, which ignores attributes at the end of a declaration. A normal member function goes through cp_parser_member_declaration, which handles the attributes properly. You can work around this bug by moving the attribute into the decl-specifier-seq, i.e. "void __attribute ((deprecated)) foo(T&)". Jason
*** Bug 36307 has been marked as a duplicate of this bug. ***
Not planning to work on this soon since there's a reasonable workaround.