[Bug c++/50456] New: attributes ignored on member templates

timj at gtk dot org gcc-bugzilla@gcc.gnu.org
Mon Sep 19 14:33:00 GMT 2011


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: unassigned@gcc.gnu.org
        ReportedBy: timj@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.



More information about the Gcc-bugs mailing list