bug-gnulib
[Top][All Lists]
Advanced

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

Re: undefined behaviour findings in bitset


From: Bruno Haible
Subject: Re: undefined behaviour findings in bitset
Date: Mon, 18 Mar 2019 22:03:18 +0100
User-agent: KMail/5.1.3 (Linux/4.4.0-141-generic; KDE/5.18.0; x86_64; ; )

Hi Akim,

> Also, the relationship with noreturn.h is not completely clear for
> me either.

There are a couple of comment in noreturn.h lines 33..41. But I agree,
some text in the documentation would be better.

> Clang 7 pretends to be GCC 4.2 (__GNUC__ __GNUC_MINOR__).

> For instance I see it already has the above fix for
> GCC 4.7, but in a different way.
> 
>  /* Use ISO C++11 syntax when the compiler supports it. */
> # if (__cplusplus >= 201103 && !(__GNUC__ == 4 && __GNUC_MINOR__ == 7)) \
>   || (_MSC_VER >= 1900)
> # define _GL_NORETURN_FUNC [[noreturn]]

Right, this snippet gets clang++ and MSVC++ support right. How about this
patch?


2019-03-18  Bruno Haible  <address@hidden>

        _Noreturn: clang and MSVC do support [[noreturn]] in C++11 mode.
        * lib/_Noreturn.h: Use [[noreturn]] if __GNUC__ and __GNUC_MINOR__
        indicate clang, or if _MSC_VER indicates MSVC++ 14.0 or newer.

diff --git a/lib/_Noreturn.h b/lib/_Noreturn.h
index 19597e0..1629cef 100644
--- a/lib/_Noreturn.h
+++ b/lib/_Noreturn.h
@@ -1,6 +1,7 @@
 #ifndef _Noreturn
-# if (201103 <= (defined __cplusplus ? __cplusplus : 0) \
-      && (!defined __GNUC__ || 4 < __GNUC__ + (8 <= __GNUC_MINOR__)))
+# if (defined __cplusplus \
+      && ((201103 <= __cplusplus && !(__GNUC__ == 4 && __GNUC_MINOR__ == 7)) \
+          || (defined _MSC_VER && 1900 <= _MSC_VER)))
 #  define _Noreturn [[noreturn]]
 # elif (201112 <= (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) \
         || 4 < __GNUC__ + (7 <= __GNUC_MINOR__))
diff --git a/m4/gnulib-common.m4 b/m4/gnulib-common.m4
index 688a1e5..20666a5 100644
--- a/m4/gnulib-common.m4
+++ b/m4/gnulib-common.m4
@@ -1,4 +1,4 @@
-# gnulib-common.m4 serial 42
+# gnulib-common.m4 serial 43
 dnl Copyright (C) 2007-2019 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -17,8 +17,9 @@ AC_DEFUN([gl_COMMON_BODY], [
   AH_VERBATIM([_Noreturn],
 [/* The _Noreturn keyword of C11.  */
 #ifndef _Noreturn
-# if (201103 <= (defined __cplusplus ? __cplusplus : 0) \
-      && (!defined __GNUC__ || 4 < __GNUC__ + (8 <= __GNUC_MINOR__)))
+# if (defined __cplusplus \
+      && ((201103 <= __cplusplus && !(__GNUC__ == 4 && __GNUC_MINOR__ == 7)) \
+          || (defined _MSC_VER && 1900 <= _MSC_VER)))
 #  define _Noreturn [[noreturn]]
 # elif (201112 <= (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) \
         || 4 < __GNUC__ + (7 <= __GNUC_MINOR__))




reply via email to

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