[Bug c++/79996] spurious -Wreturn-type on a function that calls a noreturn function

egallager at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Wed Aug 23 14:50:00 GMT 2017


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79996

Eric Gallager <egallager at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |diagnostic
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2017-08-23
                 CC|                            |egallager at gcc dot gnu.org
           See Also|                            |https://gcc.gnu.org/bugzill
                   |                            |a/show_bug.cgi?id=80140
     Ever confirmed|0                           |1

--- Comment #2 from Eric Gallager <egallager at gcc dot gnu.org> ---
(In reply to Martin Sebor from comment #0)
> With bug 79967 fixed GCC accepts non-type template parameters of function
> type declared noreturn.  C++ doesn't seem to allow the attribute in this
> context and it's unclear what the expected of such an attribute should be. 
> Even though it accepts it, GCC appears to not only silently ignore the
> attribute on the template parameter, it also loses the attribute if the
> template argument is decorated with it.  That leads to warnings such in the
> test case below where intuitively none would be expected.
> 
> If the attribute is to be accepted (perhaps as an extension) but ignored
> here GCC should issue a -Wignored-attributes warning. 

That's bug 80140.

> If accepting is, in fact an extension (i.e., C++ doesn't allow it here),
> GCC should also issue a warning with -Wpedantic.
> 
> $ cat t.c && gcc -S -Wall -Wextra -Wpedantic -xc++ t.c
> [[noreturn]] void g ();
> 
> struct A
> {
>   int foo ();
> };
> 
> int foo ()
> {
>   g ();
> }
> 
> template <void f [[noreturn]]() = g>
> struct B
> {
>   int foo ();
> };
> 
> template <void f ()>
> int B<f>::foo ()
> {
>   f ();
> }
> 
> int i = (B<>().foo (), 0);
> t.c: In member function ‘int B<f>::foo()’:
> t.c:23:1: warning: no return statement in function returning non-void
> [-Wreturn-type]
>  }
>  ^

Confirming as a separate bug since the testcase is different.


More information about the Gcc-bugs mailing list