Re: clang and _Noreturn

2017-04-26 Thread Bruno Haible
Hi Paul, > > it's better ignore which > > parts of the API will be used frequently or rarely. Better think only at > > how easy it is to remember each item. > > Even if that's the criterion, I find it easier to remember "use _GL_NORETURN > for > most noreturn cases, and use _GL_ATTRIBUTE_NORETU

Re: clang and _Noreturn

2017-04-26 Thread Bruno Haible
I wrote: > I guess I need to test things with some older versions of gcc and g++ as well, > and with MSVC, before we can jump to conclusions. Here are the results. Let 1, 2, 3, 4, 5 denote the respective positions: XX extern void foo1 (void); extern XX void foo2 (void); extern void XX foo3 (void);

Re: clang and _Noreturn

2017-04-25 Thread Paul Eggert
Bruno Haible wrote: it's better ignore which parts of the API will be used frequently or rarely. Better think only at how easy it is to remember each item. Even if that's the criterion, I find it easier to remember "use _GL_NORETURN for most noreturn cases, and use _GL_ATTRIBUTE_NORETURN for w

Re: clang and _Noreturn

2017-04-24 Thread Bruno Haible
Hi Paul, > > If we want to offer a short macro name, such as _GL_NORETURN, it should > > be usable in both places, function declarations and function pointers. > > That is, make it an alias of _GL_NORETURN_FUNCPTR. > ... > Function pointers are relatively rare compared to function definitions > a

Re: clang and _Noreturn

2017-04-24 Thread Paul Eggert
On 04/24/2017 01:38 PM, Bruno Haible wrote: Hi Paul, the only position that works for both C and C++ is the first one: _GL_NORETURN_FUNC extern void foo (void); Maybe a shorter name for this usage: _GL_NORETURN, perhaps? If we want to offer a short macro name, such as _GL_NORETURN, it sho

Re: clang and _Noreturn

2017-04-24 Thread Bruno Haible
Hi Paul, > > the only position that works for both C and C++ is the first one: > >_GL_NORETURN_FUNC extern void foo (void); > > Maybe a shorter name for this usage: _GL_NORETURN, perhaps? If we want to offer a short macro name, such as _GL_NORETURN, it should be usable in both places, functi

Re: clang and _Noreturn

2017-04-23 Thread Paul Eggert
On 04/23/2017 01:58 PM, Bruno Haible wrote: the only position that works for both C and C++ is the first one: _GL_NORETURN_FUNC extern void foo (void); Maybe a shorter name for this usage: _GL_NORETURN, perhaps? Don't some compilers complain if the storage class ('extern', here) is not fir

Re: clang and _Noreturn

2017-04-23 Thread Bruno Haible
Hi Paul, > Although this will work for GCC and Clang, I suppose it might cause other > compilers to generate slightly-less-efficient code, because they won't know > that > print_and_abort does not return. Good point. Yes. > To avoid that problem, how about this further patch? Yes, this fits

Re: clang and _Noreturn

2017-04-23 Thread Paul Eggert
Bruno Haible wrote: 1) If _Noreturn does not apply to function pointers, only to functions, we should better avoid it. It's an ill-defined standard's feature. Hmm, well, we cannot avoid _Noreturn in general, since the standard requires it for functions defined by the standard. Admittedly t

Re: clang and _Noreturn

2017-04-23 Thread Bruno Haible
Hi Paul, Thanks for explaining. > > What is the semantic difference between _Noreturn and > > __attribute_noreturn__? > > __attribute__ ((__noreturn__)), which the latter expands to, also works with > function pointers, whereas _Noreturn does not. The distinction can matter > when a > functio

Re: clang and _Noreturn

2017-04-22 Thread Paul Eggert
Bruno Haible wrote: What is the semantic difference between _Noreturn and __attribute_noreturn__? __attribute__ ((__noreturn__)), which the latter expands to, also works with function pointers, whereas _Noreturn does not. The distinction can matter when a function's address is assigned to a f

clang and _Noreturn

2017-04-22 Thread Bruno Haible
On Mac OS X 10.12 (with gcc -> clang), with CPPFLAGS=-Wall, I get this warning: obstack.c:351:31: warning: incompatible pointer types initializing 'void (*)(void) __attribute__((noreturn))' with an expression of type 'void (void)' [-Wincompatible-pointer-types] __attribute_noreturn__ void (*obst