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++/84158] [6/7/8 Regression] missing -Wreturn-type due to incorrect handling of attributes for template specializations


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

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