http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60625
Bug ID: 60625 Summary: attributes on template member function definition inside class definition not supported Product: gcc Version: 4.9.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: petschy at gmail dot com struct Foo { template<int U> // error: attributes are not allowed on a function-definition static int Bar() __attribute__((always_inline)) { return U; } // no error, although this is a fn definition, too static int Baz(bool x) __attribute__((always_inline)) { return x ? Bar<5>() : Bar<42>(); } }; g++ -c 20140323-force_inline.cpp 20140323-force_inline.cpp:5:20: error: attributes are not allowed on a function-definition static int Bar() __attribute__((always_inline)) Tried with all minor versions from 4.4 to 4.9, same results. Supporting attributes on in-class defined template members would be really useful, or rather, convenient. Otherwise, one have to declare the function with the attribute inside the class, then define it outside the class. For short and simple functions this is rather tedious. Regards, Peter