Dwight Guth wrote:
We use GLIBC's header files, but we do not define the __GNUC__ macro.
Ah, in that case there's a simple solution: your compiler should define __GNUC__. That's what Clang does.
we could define __restrict as a keyword equivalent to restrict. In fact that is probably what I am going to have to do if we can't come to some kind of consensus here.
Even if we came to a consensus, it would take years for the fixes to propagate everywhere and in the meantime your compiler's users would have problems. So really, it needs to support __restrict and define __GNUC__, like Clang does.
This is also consistent with the fact that the documentation generated in config.h for AC_C_RESTRICT says "Do not define if restrict is supported directly." (although this documentation seems inconsistent with the online documentation, which correctly explains the current behavior).
Yes, that's a typo in that comment. It should say "supported only directly". Anyway, does the attached hacky patch fix the problem?
>From cd6c575c532931d9e7339be9f0263ff66a2d7e17 Mon Sep 17 00:00:00 2001 From: Paul Eggert <egg...@cs.ucla.edu> Date: Mon, 22 Feb 2016 23:07:02 -0800 Subject: [PATCH] AC_C_RESTRICT: port better to non-GCC + glibc Problem reported by Dwight Guth in: http://lists.gnu.org/archive/html/bug-autoconf/2016-02/msg00006.html * lib/autoconf/c.m4 (AC_C_RESTRICT): Prefer __restrict__ to __restrict. Also, fix and update some comments. --- lib/autoconf/c.m4 | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/lib/autoconf/c.m4 b/lib/autoconf/c.m4 index 5b25c62..fe87dbf 100644 --- a/lib/autoconf/c.m4 +++ b/lib/autoconf/c.m4 @@ -1855,8 +1855,10 @@ AN_IDENTIFIER([restrict], [AC_C_RESTRICT]) AC_DEFUN([AC_C_RESTRICT], [AC_CACHE_CHECK([for C/C++ restrict keyword], [ac_cv_c_restrict], [ac_cv_c_restrict=no - # The order here caters to the fact that C++ does not require restrict. - for ac_kw in __restrict __restrict__ _Restrict restrict; do + # Put '__restrict__' first, to avoid problems with glibc and non-GCC; see: + # http://lists.gnu.org/archive/html/bug-autoconf/2016-02/msg00006.html + # Put 'restrict' last, because C++ lacks it. + for ac_kw in __restrict__ __restrict _Restrict restrict; do AC_COMPILE_IFELSE( [AC_LANG_PROGRAM( [[typedef int *int_ptr; @@ -1876,13 +1878,13 @@ AC_DEFUN([AC_C_RESTRICT], AH_VERBATIM([restrict], [/* Define to the equivalent of the C99 'restrict' keyword, or to nothing if this is not supported. Do not define if restrict is - supported directly. */ + supported only directly. */ #undef restrict -/* Work around a bug in Sun C++: it does not support _Restrict or +/* Work around a bug in Sun C++ 5.13: it does not support _Restrict or __restrict__, even though the corresponding Sun C compiler ends up with - "#define restrict _Restrict" or "#define restrict __restrict__" in the - previous line. Perhaps some future version of Sun C++ will work with - restrict; if so, hopefully it defines __RESTRICT like Sun C does. */ + "#define restrict _Restrict" or "#define restrict __restrict__". + Perhaps some future version of Sun C++ will work with restrict; + if so, hopefully it defines __RESTRICT like Sun C does. */ #if defined __SUNPRO_CC && !defined __RESTRICT # define _Restrict # define __restrict__ -- 2.5.0