This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/84158] [6/7/8 Regression] missing -Wreturn-type due to incorrect handling of attributes for template specializations
- From: "msebor at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 01 Feb 2018 15:35:45 +0000
- Subject: [Bug c++/84158] [6/7/8 Regression] missing -Wreturn-type due to incorrect handling of attributes for template specializations
- Auto-submitted: auto-generated
- References: <bug-84158-4@http.gcc.gnu.org/bugzilla/>
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