https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84158
--- Comment #4 from Martin Sebor <msebor at gcc dot gnu.org> --- (In reply to Jakub Jelinek from comment #2) > I actually think it is the right thing that the attributes from templates > are inherited by specializations. That cannot be correct. Because there is no way to remove an attribute from a declaration such a design would make it impossible to declare a specialization that differed from the primary. Here's a modified example that should bring the problem into focus: template <class T> T __attribute__ ((noreturn)) f (T) { __builtin_abort (); } template <> int f (int) { return 0; } // bogus warning here int g (int i) { f (i); // missing -Wreturn-type } t.C: In function ‘T f(T) [with T = int]’: t.C:3:34: warning: function declared ‘noreturn’ has a ‘return’ statement template <> int f (int) { return 0; } ^ t.C:3:34: warning: ‘noreturn’ function does return