Hi Paul, > I thought we had established that in some cases one should apply both > _Noreturn and __attribute__ ((__noreturn__)) to the same declaration? I > don't see that in this module.
Apparently we've been thinking at different solutions of the clang problem (which, for type checking / assignment purposes, considers _Noreturn to be different from __attribute__((__noreturn__))). My solution in the proposed noreturn.h is to #define _GL_NORETURN_FUNC __attribute__ ((__noreturn__)) #define _GL_NORETURN_FUNCPTR __attribute__ ((__noreturn__)) in this case. So clang won't warn. You have been thinking of this? #define _GL_NORETURN_FUNC _Noreturn #define _GL_NORETURN_FUNCPTR _Noreturn __attribute__ ((__noreturn__)) > Also, I hope we're not envisioning a lot of replacement of _Noreturn > with _GL_NORETURN_FUNC in other modules. No, most of these functions (dfaerror, openat_save_fail, _Exit, xalloc_die, ...) are not likely to be stored in function pointers. > As I understand it, > _GL_NORETURN_FUNC is needed only for functions that one wants to take > addresses of, and to store these addresses in _GL_NORETURN_FUNCPTR > variables. Most existing modules don't need to do this, and so can > continue to use _Noreturn. This point should be made in the comments. Good point. And for C++ support (other than g++ and MSVC) as well. I'm squashing in this comment change: --- a/lib/noreturn.h +++ b/lib/noreturn.h @@ -29,6 +29,16 @@ _GL_NORETURN_FUNC is for use in function declarations and function definitions. _GL_NORETURN_FUNCPTR is for use on function pointers. + + Comparison of this file with <stdnoreturn.h>: + <stdnoreturn.h> defines a macro (or keyword) _Noreturn that declares + a function to be non-returning. _Noreturn is only for use in function + declarations and function definitions. + Therefore, if the non-returning functions you have to declare are unlikely + to be accessed through function pointers, and if the efficiency with C++ + compilers other than g++, clang, MSVC++ is not an issue to you, you can use + module 'stdnoreturn' instead of this one, and _Noreturn instead of + _GL_NORETURN_FUNC. */ /* Declares that a function is nonreturning.