http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50456
Bug #: 50456 Summary: attributes ignored on member templates Classification: Unclassified Product: gcc Version: 4.5.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassig...@gcc.gnu.org ReportedBy: t...@gtk.org Decorating a member template with __attribute__((error)) should trigger compiler errors like declaring regular methods does. (A similar bug exists about __attribute__((warning))). Example code: template<class A> struct Object; template<> struct Object<float> { template<class A> static void should_error (A a) __attribute__ ((error ("Calling this function should trigger a compiler error"))) ; }; int main (int argc, char *argv[]) { typedef Object<float> FloatObject; FloatObject::should_error (7); return 0; } // g++ -Wall -O2 x.cc && ./a.out Actual result: x.cc:(.text+0xa): undefined reference to `void Object<float>::should_error<int>(int)' Expected result: x.cc:10: error: call to ‘Object<float>::should_error’ declared with attribute error: Calling this function should trigger a compiler error Observed with g++-4.4 and g++-4.5 (Ubuntu/Linaro 4.5.1-7ubuntu2) 4.5.1.