https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80496
Bug ID: 80496
Summary: missing diagnostic regarding noreturn mismatch in
function pointer initialization
Product: gcc
Version: 6.3.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: bruno at clisp dot org
Target Milestone: ---
A mismatch regarding __attribute__((__noreturn__)) in a function pointer
initialization generates a warning in C mode, but not in C++ mode.
$ cat noreturn2.cc
void func1 (void) { for (;;); }
[[ noreturn ]] void func2 (void) { for (;;); }
__attribute__ ((__noreturn__)) void func3 (void) { for (;;); }
void (*fptr11) (void) = func1;
void (*fptr12) (void) = func2;
void (*fptr13) (void) = func3;
__attribute__ ((__noreturn__)) void (*fptr31) (void) = func1; /* expected:
warning */
__attribute__ ((__noreturn__)) void (*fptr32) (void) = func2;
__attribute__ ((__noreturn__)) void (*fptr33) (void) = func3;
$ g++ --version | head -n 1
g++ (GCC) 6.3.0
$ g++ -std=c++11 -Wall -c noreturn2.cc
I would have expected a warning in the declaration of fptr31.