[PATCH] D131351: [C] Default implicit function pointer conversions diagnostic to be an error

Martin Storsjö via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Aug 12 04:33:40 PDT 2022


mstorsjo added a comment.

In D131351#3718725 <https://reviews.llvm.org/D131351#3718725>, @aaron.ballman wrote:

> In D131351#3718421 <https://reviews.llvm.org/D131351#3718421>, @mstorsjo wrote:
>
>> I found another case of this warning, which is kinda borderline whether it really is an error not:
>>
>>   #include <stdlib.h>
>>   static _Noreturn void my_exit(void) {
>>     exit(42);
>>   }
>>   __attribute__((noreturn)) void (*handler)(void) = my_exit;
>>
>> The fix is simple though, just be consistent with `_Noreturn` vs `__attribute__((noreturn))` on both function and function pointer.
>
> Oh wow, that one is neat, weird, and I'm not certain what I think about it yet.

FWIW, the source of the code here is a piece of code from glibc, distributed as part of gnulib and in gettext (in various older/newer copies of it). The bug has itself been fixed in gnulib already almost 2 years ago, as result of the Clang warning at the time: https://git.savannah.gnu.org/cgit/gnulib.git/commit/lib/obstack.c?id=0cc39712803ade7b2d4b89c36b143dad72404063 However in this case, a (potentially old) packaged tarball of gettext contained two older copies of the file.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D131351/new/

https://reviews.llvm.org/D131351



More information about the cfe-commits mailing list