[Bug c++/13440] New: attributes lost in explicit template specializations

dannysmith at gcc dot gnu dot org gcc-bugzilla@gcc.gnu.org
Fri Dec 19 09:53:00 GMT 2003


Parsing of explicit template specializations loses attribute
directive if the attributes are declared immediately after the the class-key
rather than at the curly bracket end of class definition.

eg:
==================================================
// attrib11.C
template <class intT> struct Bar{};

template<> struct Bar<int>
{
   char c;
   int i;
} __attribute__ ((packed)); // is packed.


template<> struct __attribute__ ((packed)) Bar<short>
{
   char c;
   int i;
};  // is _not_ packed

Bar<int> iBar;
Bar<short> sBar;

char test[sizeof iBar == sizeof sBar ? 1 : -1];

// end attrib11.C
==================================================

This has significance to dll[im/ex]port attribute, since
the second form (with __attribute__(()) replaced by __declspec())
is the one accepted by the native w32 compiler.

Danny

-- 
           Summary: attributes lost in explicit template specializations
           Product: gcc
           Version: 3.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: dannysmith at gcc dot gnu dot org
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i686-pc-mingw32
  GCC host triplet: i686-pc-mingw32
GCC target triplet: i686-pc-mingw32


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13440



More information about the Gcc-bugs mailing list