bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 01/19] * m4/gnulib-common.m4 (gl_COMMON_BODY): Add _Noreturn.


From: Bruno Haible
Subject: Re: [PATCH 01/19] * m4/gnulib-common.m4 (gl_COMMON_BODY): Add _Noreturn.
Date: Tue, 12 Jul 2011 00:15:43 +0200
User-agent: KMail/1.9.9

Hi Paul,

> (1) add support for the draft C1X _Noreturn keyword,
> (2) add support for the draft C1X <stdnoreturn.h> include, and
> (3) have the rest of gnulib use (1) and (2)

In patches [06] to [13], you use _Noreturn.
In patches [14] to [18], you use noreturn.
Which seems inconsistent.

Is it better to use the C identifier '_Noreturn' (1) or 'noreturn' (2)?

1) One one hand, it appears that the intent of the ISO C committee is that
'_Noreturn' is (like '_Bool') the keyword that only C wizards know about,
whereas 'noreturn' (like 'bool') is the identifier that everyone uses,

2) BUT! The ISO C++ draft
<http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2011/n3242.pdf>
does not specify _Noreturn but it specifies a different syntax:

  [[noreturn]] void f (void);

3) On the other hand, 'noreturn' is already used as a keyword by Microsoft
C compilers. Cf.
<http://msdn.microsoft.com/en-us/library/k6ktzx3s(v=vs.80).aspx>
Here's a grep of the MSVC header files:

$ grep noreturn *
eh.h:_CRTIMP __declspec(noreturn) void __cdecl terminate(void);
eh.h:_CRTIMP __declspec(noreturn) void __cdecl unexpected(void);
process.h:_CRTIMP __declspec(noreturn) void __cdecl abort(void);
process.h:_CRTIMP __declspec(noreturn) void __cdecl exit(int);
process.h:_CRTIMP __declspec(noreturn) void __cdecl _exit(int);
setjmp.h:_CRTIMP __declspec(noreturn) void __cdecl longjmp(jmp_buf, int);
stdlib.h:_CRTIMP __declspec(noreturn) void   __cdecl abort(void);
stdlib.h:_CRTIMP __declspec(noreturn) void   __cdecl exit(int);
stdlib.h:_CRTIMP __declspec(noreturn) void   __cdecl _exit(int);

and of the mingw header files:

$ grep noreturn *
assert.h:       __attribute__ ((noreturn))
stdlib.h:#define        _ATTRIB_NORETURN        __attribute__ ((noreturn))
windef.h:#define DECLSPEC_NORETURN __declspec(noreturn)


In summary, it looks to me that the ISO C and ISO C++ committees need to
do some more work to align the syntaxes.
  extern noreturn void _Exit (void);
vs.
  extern [[noreturn]] void _Exit (void);


And on the gnulib side, either we should wait until the ISO C and ISO C++
drafts have converged, or we should use _Noreturn everywhere and not
use 'noreturn' (1. because of C++, 2. because of Microsoft's compiler).

Bruno
-- 
In memoriam Zahra Kazemi <http://en.wikipedia.org/wiki/Zahra_Kazemi>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]