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++/79996] New: spurious -Wreturn-type on a function that calls a noreturn function


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

            Bug ID: 79996
           Summary: spurious -Wreturn-type on a function that calls a
                    noreturn function
           Product: gcc
           Version: 7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: msebor at gcc dot gnu.org
  Target Milestone: ---

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.  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]
 }
 ^

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