-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add more _noreturn_ attributes as suggested my -Wsuggest-attribute=noreturn #223
base: main
Are you sure you want to change the base?
Conversation
I think this is overkill, as you can see here, even with |
one can use STDC_VERSION in noreturn.h There is the suggestion to use
|
I wonder if we should not just use _Noreturn and add compatibility defines for that if it is not present. |
But why? If you define a macro anyway, just call it like the official C11 name. |
It's unclear to me what is the official name, if it is the define that comes from the header or the internal keyword. The plan is of course to use the standard one.
This suggests that the |
The C11 keyword is |
including stdnoreturn.h breaks gcc if you use _attribute_ ((noreturn)). I had this problem last year compiling ezmlm-idx. ezmlm-idx uses this macro in die.h and cgi.h. I managed to find what the issue is. Here are two examples. The first example ignores noreturn because of stdnoreturn.h. Without stdnoreturn.h, it does the job. The second examples does the required job of adding noreturn attribute even with stdnoreturn.h included. The bug is mentioned here. ** Example1 problem with including stdnoreturn.h
Workaround is to use attribute ((noreturn)) instead of attribute ((noreturn)) ** Example2
|
What works should be something like this: #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L
#include <stdnoreturn.h>
#elif defined(__GNUC__)
#define noreturn __attribute__((__noreturn__))
#else
#define noreturn
#endif |
…return Since we have that attribute available anyway we can as well add it to more functions to allow the compiler to generate better code.
ab3e812
to
3a1bcdb
Compare
I felt that converting |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If there is anything happening about "noreturn" vs "noreturn", it would go in a separate commit?
All good with the ()
to (void)
conversion as well.
If we generally agree to just call it |
Since we have that attribute available anyway we can as well add it to more functions to allow the compiler to generate better code.