Paul Eggert wrote:
> +2025-06-27 Paul Eggert <[email protected]>
> +
> + _Noreturn: pacify gcc -std=gnu99 -Wpedantic
> + Problem reported by Helmut Eller <https://bugs.gnu.org/78903>.
> + * lib/_Noreturn.h (_Noreturn):
> + * m4/gnulib-common.m4 (gl_COMMON_BODY): Prefer __attribute__
> + ((__noreturn__)) to _Noreturn if __STDC_VERSION__ < 201112, to
> + pacify gcc -std=gnu99 -Wpedantic. Simplify. Do not bother
> + suggesting -D_GL_WORK_AROUND_LLVM_BUG_59792; suggest the
> + equivalent -D_Noreturn= instead, and remove the test on
> + _GL_WORK_AROUND_LLVM_BUG_59792.
The "Simplify." part of this change caused a regression. Fortunately
caught by the weekly CI. Namely, a compilation error on Solaris.
On Solaris 11.4:
g++ -m64 -DHAVE_CONFIG_H -DEXEEXT=\"\" -DEXEEXT=\"\" -I. -I../../gltests -I..
-DGNULIB_STRICT_CHECKING=1 -DIN_GNULIB_TESTS=1 -I. -I../../gltests -I..
-I../../gltests/.. -I../gllib -I../../gltests/../gllib -I/root/include -Wall
-DCONTINUE_AFTER_ASSERT -D_REENTRANT -Wno-error -g -O2 -MT test-assert-h-c++.o
-MD -MP -MF $depbase.Tpo -c -o test-assert-h-c++.o
../../gltests/test-assert-h-c++.cc &&\
mv -f $depbase.Tpo $depbase.Po
In file included from /usr/include/sys/time.h:462,
from ../gllib/sys/time.h:46,
from /usr/include/sys/select.h:27,
from ../gllib/sys/select.h:43,
from /usr/include/sys/types.h:667,
from ../gllib/sys/types.h:46,
from ../gllib/stdio.h:83,
from /usr/include/iso/wchar_iso.h:32,
from
/usr/gcc/14/lib/gcc/x86_64-pc-solaris2.11/14.2.0/include-fixed/wchar.h:18,
from ../gllib/wchar.h:83,
from /usr/gcc/14/include/c++/14.2.0/cwchar:44,
from /usr/gcc/14/include/c++/14.2.0/bits/postypes.h:40,
from /usr/gcc/14/include/c++/14.2.0/iosfwd:42,
from /usr/gcc/14/include/c++/14.2.0/ios:40,
from /usr/gcc/14/include/c++/14.2.0/ostream:40,
from /usr/gcc/14/include/c++/14.2.0/iostream:41,
from ../../gltests/test-assert-h-c++.cc:26:
../gllib/stdlib.h:866:1: error: ‘_Noreturn’ does not name a type
866 | _GL_FUNCDECL_RPL (abort, _Noreturn void, (void), );
| ^~~~~~~~~~~~~~~~
../gllib/stdlib.h: In member function ‘gnulib::_gl_abort_wrapper::operator
type() const’:
../gllib/stdlib.h:867:1: error: ‘::rpl_abort’ has not been declared
867 | _GL_CXXALIAS_RPL (abort, void, (void));
| ^~~~~~~~~~~~~~~~
*** Error code 1
On Solaris 11 OmniOS:
g++ -DHAVE_CONFIG_H -DEXEEXT=\"\" -DEXEEXT=\"\" -I. -I../../gltests -I..
-DGNULIB_STRICT_CHECKING=1 -DIN_GNULIB_TESTS=1 -I. -I../../gltests -I..
-I../../gltests/.. -I../gllib -I../../gltests/../gllib -I/root/include -Wall
-DCONTINUE_AFTER_ASSERT -D_REENTRANT -Wno-error -g -O2 -MT test-assert-h-c++.o
-MD -MP -MF $depbase.Tpo -c -o test-assert-h-c++.o
../../gltests/test-assert-h-c++.cc &&\
mv -f $depbase.Tpo $depbase.Po
In file included from /usr/include/sys/time.h:489,
from ../gllib/sys/time.h:46,
from /usr/include/sys/select.h:53,
from ../gllib/sys/select.h:43,
from /usr/include/sys/types.h:672,
from ../gllib/sys/types.h:46,
from ../gllib/stdio.h:83,
from /usr/include/iso/wchar_iso.h:54,
from
/opt/gcc-14/lib/gcc/x86_64-pc-solaris2.11/14.2.0/include-fixed/wchar.h:40,
from ../gllib/wchar.h:83,
from /opt/gcc-14/include/c++/14.2.0/cwchar:44,
from /opt/gcc-14/include/c++/14.2.0/bits/postypes.h:40,
from /opt/gcc-14/include/c++/14.2.0/iosfwd:42,
from /opt/gcc-14/include/c++/14.2.0/ios:40,
from /opt/gcc-14/include/c++/14.2.0/ostream:40,
from /opt/gcc-14/include/c++/14.2.0/iostream:41,
from ../../gltests/test-assert-h-c++.cc:26:
../gllib/stdlib.h:866:1: error: '_Noreturn' does not name a type
866 | _GL_FUNCDECL_RPL (abort, _Noreturn void, (void), );
| ^~~~~~~~~~~~~~~~
../gllib/stdlib.h: In member function 'gnulib::_gl_abort_wrapper::operator
type() const':
../gllib/stdlib.h:867:1: error: '::rpl_abort' has not been declared
867 | _GL_CXXALIAS_RPL (abort, void, (void));
| ^~~~~~~~~~~~~~~~
gmake[4]: *** [Makefile:27318: test-assert-h-c++.o] Error 1
This patch fixes it.
Was there any reason to remove the
'(!defined __cplusplus || defined __clang__) && '
part of the condition?
2025-06-30 Bruno Haible <[email protected]>
_Noreturn: Fix compilation in C++ mode on Solaris (regr. 2025-06-27).
* lib/_Noreturn.h (_Noreturn): Restore C++ mode handling.
* m4/gnulib-common.m4 (gl_COMMON_BODY): Likewise.
diff --git a/lib/_Noreturn.h b/lib/_Noreturn.h
index 8e63387914..d42f15eee6 100644
--- a/lib/_Noreturn.h
+++ b/lib/_Noreturn.h
@@ -27,7 +27,8 @@
This rare bug can be worked around by compiling with 'clang -D_Noreturn=',
though the workaround may generate many false-alarm warnings. */
#ifndef _Noreturn
-# if 201112 <= (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0)
+# if ((!defined __cplusplus || defined __clang__) \
+ && (201112 <= (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0)))
/* _Noreturn works as-is. */
# elif (2 < __GNUC__ + (8 <= __GNUC_MINOR__) || defined __clang__ \
|| 0x5110 <= __SUNPRO_C)
diff --git a/m4/gnulib-common.m4 b/m4/gnulib-common.m4
index d525d8b1fa..034dae69e6 100644
--- a/m4/gnulib-common.m4
+++ b/m4/gnulib-common.m4
@@ -1,5 +1,5 @@
# gnulib-common.m4
-# serial 112
+# serial 113
dnl Copyright (C) 2007-2025 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -70,7 +70,8 @@ AC_DEFUN([gl_COMMON_BODY]
This rare bug can be worked around by compiling with 'clang -D_Noreturn=',
though the workaround may generate many false-alarm warnings. */
#ifndef _Noreturn
-# if 201112 <= (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0)
+# if ((!defined __cplusplus || defined __clang__) \
+ && (201112 <= (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0)))
/* _Noreturn works as-is. */
# elif _GL_GNUC_PREREQ (2, 8) || defined __clang__ || 0x5110 <= __SUNPRO_C
/* Prefer __attribute__ ((__noreturn__)) to plain _Noreturn even if the