-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Move the [[noreturn]]
attribute to the front of the declaration
#12468
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
Conversation
* Needed in C++17 Signed-off-by: Dhruv Maroo <dhruvmaru007@gmail.com>
Thanks for pointing this out. I was not aware that attributes had stronger constraints than the The proposed fix is fine, but I'm concerned that the problem will come back over and over again as we add new "noreturn" functions to the runtime system and compile with pre-C23 compilers. That |
Wouldn't updating the CI to use a newer version of the compiler (C23 compliant) prevent any non-compliant changes from being merged? I think it may (?) be safe to assume that this behavior of the |
Yes, eventually. Right now, C23 is not yet published as a standard, support by GCC and Clang is spotty, and C23 is not their default mode, so it will take some time and some effort to get C23 in CI. |
Makes sense. |
I'm making slow progress on this issue. It turns out that one of our CI machines runs the latest Ubuntu version, which has clang version 15, which supports a lot of C23, including the
in that it turns C23 features on and pretends to be C23 compliant. With that I can see the "misplaced attributes" errors, check that this PR fixes a number of them, but leaves out some others, which I could fix easily. (I'll add the fix to this PR soon.) So, it seems to work well as a "C23 readiness" check, and could be integrated in the Jenkins CI at Inria. |
…ntinued Also needed in C 23, meaning it must be applied to source files and internal header files as well.
Ah okay. It's weird that one needs to manually set |
We need to do something here, since #12235 introduced an incompatibility with C++17 and the upcoming C23: either we revert #12235 or move forward and merge this PR. I move to merge this PR, and try to have it tested by Jenkins CI as outlined above. If it doesn't work it will always be possible to revert both this PR and #12235. |
Your plan (merge here + improve CI) sounds excellent to me. Is there something that would help besides this bystander opinion? (Note: it would be nice to have a comment on the CAMLnoret definition that it needs to be placed at the beginning of the declaration.) |
Good idea! See 8c02bd9. Time to merge! |
We're out of luck: clang 17 refuses to un-define
Checkmate! I give up on trying to test C23 conformance before C23 is officially released. Too bad... |
…aml#12468) * Move the `[[noreturn]]` attribute to the front of the declarations in <caml/*.h> Needed in C++17. * Move the `[[noreturn]]` attribute to the front of the definitions Also needed in C 23, meaning that the move must be applied to source files and internal header files as well. * Document that `CAMLnoret` must occur first in declarations Signed-off-by: Dhruv Maroo <dhruvmaru007@gmail.com> Co-authored-by: Xavier Leroy <xavier.leroy@college-de-france.fr>
C++17 requires attributes to be placed before the declaration specifiers. GCC 12 (and greater) seem to fail to compile when this syntax is not followed. There are no behavioral changes, only the attribute's position is moved.
Similar issue: jarro2783/cxxopts#353.