This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/60625] New: attributes on template member function definition inside class definition not supported


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]