bug-gnulib
[Top][All Lists]
Advanced

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

Re: static_assert in G++


From: Bruno Haible
Subject: Re: static_assert in G++
Date: Thu, 10 Jan 2019 21:08:15 +0100
User-agent: KMail/5.1.3 (Linux/4.4.0-141-generic; KDE/5.18.0; x86_64; ; )

Hi Reuben,

>     verify: Fix syntax error with GCC 4.6 in C++ mode.
> 
> This is odd, since the GCC web page on C++11 support:
> https://gcc.gnu.org/projects/cxx-status.html#cxx11
> 
> says that static assertions have been supported for C++ since GCC 4.3:

See the discussion on the mailing list:
https://lists.gnu.org/archive/html/bug-gnulib/2011-04/msg00115.html

Continuing with the next versions of g++:

$ g++-version 4.3.6 -S foo1.cc
foo1.cc:2: error: expected constructor, destructor, or type conversion before 
'(' token
$ g++-version 4.4.7 -S foo1.cc
foo1.cc:2: error: expected constructor, destructor, or type conversion before 
'(' token
$ g++-version 4.5.4 -S foo1.cc
foo1.cc:2:15: error: expected constructor, destructor, or type conversion 
before '(' token
$ g++-version 4.6.4 -S foo1.cc
foo1.cc:2:15: error: expected constructor, destructor, or type conversion 
before '(' token
$ g++-version 4.7.3 -S foo1.cc
foo1.cc:2:15: error: expected constructor, destructor, or type conversion 
before '(' token
$ g++-version 4.8.5 -S foo1.cc
foo1.cc:2:15: error: expected constructor, destructor, or type conversion 
before '(' token
 static_assert (sizeof (long) > 1, "long too small");
               ^
$ g++-version 4.9.4 -S foo1.cc
foo1.cc:2:15: error: expected constructor, destructor, or type conversion 
before '(' token
 static_assert (sizeof (long) > 1, "long too small");
               ^
$ g++-version 5.5.0 -S foo1.cc
foo1.cc:2:15: error: expected constructor, destructor, or type conversion 
before '(' token
 static_assert (sizeof (long) > 1, "long too small");
               ^
$ g++-version 6.5.0 -S foo1.cc
$ g++-version 7.4.0 -S foo1.cc
$ g++-version 8.2.0 -S foo1.cc


I'm therefore applying this patch:


2019-01-10  Bruno Haible  <address@hidden>

        verify: Enable _GL_HAVE_STATIC_ASSERT for recent G++ versions.
        Reported by Reuben Thomas <address@hidden>.
        * lib/verify.h (_GL_HAVE_STATIC_ASSERT): Define for g++ versions >= 6.

diff --git a/lib/verify.h b/lib/verify.h
index b2e5f64..6930645 100644
--- a/lib/verify.h
+++ b/lib/verify.h
@@ -26,7 +26,7 @@
    here generates easier-to-read diagnostics when verify (R) fails.
 
    Define _GL_HAVE_STATIC_ASSERT to 1 if static_assert works as per C++11.
-   This will likely be supported by future GCC versions, in C++ mode.
+   This is supported by GCC 6.1.0 and later, in C++ mode.
 
    Use this only with GCC.  If we were willing to slow 'configure'
    down we could also use it with other compilers, but since this
@@ -36,9 +36,7 @@
      && !defined __cplusplus)
 # define _GL_HAVE__STATIC_ASSERT 1
 #endif
-/* The condition (99 < __GNUC__) is temporary, until we know about the
-   first G++ release that supports static_assert.  */
-#if (99 < __GNUC__) && defined __cplusplus
+#if (6 <= __GNUC__) && defined __cplusplus
 # define _GL_HAVE_STATIC_ASSERT 1
 #endif
 




reply via email to

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