http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49377
Summary: Template specialization attributes cause type mismatches when used Product: gcc Version: 4.6.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassig...@gcc.gnu.org ReportedBy: rmor...@nvidia.com This is similar to PR 45642, but is not fixed by the patch for that bug. I originally ran into this with 4.6.0, but I also see the behavior with a freshly-updated and built svn gcc (revision 174959). The reduced testcase is pretty simple: ---------------------------------------8<----------------------------------- template <typename T, int N> class v; template <typename T> class v<T,2> { v() { }; } __attribute__((__may_alias__)); typedef v<float,2> float2; class a { void f(float2 &point); float2 d; }; void a::f(float2 &point) { } ---------------------------------------8<----------------------------------- No special compile options, the implementation of a::f isn't matched up with the member: $ g++ -c test.cpp test.cpp:14:6: error: prototype for ‘void a::f(float2&)’ does not match any in class ‘a’ test.cpp:10:10: error: candidate is: void a::f(float2&) $ gcc -v Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/home/xbobx/src/gcc/install-174959/libexec/gcc/x86_64-unknown-linux-gnu/4.7.0/lto-wrapper Target: x86_64-unknown-linux-gnu Configured with: ../gcc/configure --prefix=/home/xbobx/src/gcc/install-174959/ --enable-languages=c,c++ --disable-multilib Thread model: posix gcc version 4.7.0 20110611 (experimental) (GCC) If I remove the attribute on the template specialization _or_ the float2 data field 'd', the test compiles fine. The bug also occurs if "float2" is used in other ways between the declaration of class a and the a::f definition (such as in another class).