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

--- Comment #1 from Martin Sebor <msebor at gcc dot gnu.org> ---
Another inconsistency is that when the noreturn attributes decorates a function
parameter that is a pointer to a function, C considers it to be a part of the
function's type while C++ does not.  That means that some otherwise valid code
that's accepted in C++ is rejected in C.

$ (set -x && cat z.c && for lang in c c++; do gcc -S -Wall -Wunused -Wpedantic
-x$lang z.c; done)
+ cat z.c
int f_ptr_noreturn (void (*fp)(void) __attribute__((noreturn)));

int f_ptr_noreturn (void (*fp)(void))
{
  fp (); 
}
+ for lang in c c++
+ /ssd/build/gcc-git/gcc/xgcc -B /ssd/build/gcc-git/gcc -S -Wall -Wunused
-Wpedantic -xc z.c
z.c:3:5: error: conflicting types for ‘f_ptr_noreturn’
 int f_ptr_noreturn (void (*fp)(void))
     ^~~~~~~~~~~~~~
z.c:1:5: note: previous declaration of ‘f_ptr_noreturn’ was here
 int f_ptr_noreturn (void (*fp)(void) __attribute__((noreturn)));
     ^~~~~~~~~~~~~~
z.c: In function ‘f_ptr_noreturn’:
z.c:6:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
+ for lang in c c++
+ /ssd/build/gcc-git/gcc/xgcc -B /ssd/build/gcc-git/gcc -S -Wall -Wunused
-Wpedantic -xc++ z.c
z.c: In function ‘int f_ptr_noreturn(void (*)())’:
z.c:6:1: warning: no return statement in function returning non-void
[-Wreturn-type]
 }
 ^

Reply via email to