bug-autoconf
[Top][All Lists]
Advanced

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

Re: AC_C_CONST fails with -Werror


From: Paul Eggert
Subject: Re: AC_C_CONST fails with -Werror
Date: Wed, 31 Aug 2011 23:22:17 -0700
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.20) Gecko/20110805 Thunderbird/3.1.12

On 08/31/11 17:06, Dan Kegel wrote:

> Here's a patch that seems to do the trick, only very lightly tested.

Thanks.  Ralf Wildenhues and Ralf Corsepius are both correct that
people shouldn't be configuring with -Werror.  Still, if it's bugging
people it's probably worth fixing.

I installed the following slightly-different patch; could you please
give it a try?  The difference is that it tries to avoid warnings
that future GCCs might issue.

AC_C_CONST: don't reject gcc -Werror -Wall
* lib/autoconf/c.m4 (AC_C_CONST): Don't reject gcc when it is used
with -Werror -Wall during configuring.  It's unwise to use GCC
that way, but apparently enough people do it nowadays that it's an
issue.  These days nobody uses the old compilers that the old
tests reject, so we can't test this fix against them, but it's
more important to work with modern GCC (even when misused) than to
work with no-longer-used compilers.  Problem reported by Shevek in
<http://lists.gnu.org/archive/html/bug-autoconf/2008-11/msg00007.html>
and raised again by Dan Kegel in
<http://lists.gnu.org/archive/html/bug-autoconf/2011-08/msg00020.html>.
diff --git a/lib/autoconf/c.m4 b/lib/autoconf/c.m4
index e4b807b..88785d1 100644
--- a/lib/autoconf/c.m4
+++ b/lib/autoconf/c.m4
@@ -1660,11 +1660,11 @@ esac
 AC_DEFUN([AC_C_CONST],
 [AC_CACHE_CHECK([for an ANSI C-conforming const], ac_cv_c_const,
 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],
-[[/* FIXME: Include the comments suggested by Paul. */
+[[
 #ifndef __cplusplus
-  /* Ultrix mips cc rejects this.  */
+  /* Ultrix mips cc rejects this sort of thing.  */
   typedef int charset[2];
-  const charset cs;
+  const charset cs = { 0, 0 };
   /* SunOS 4.1.1 cc rejects this.  */
   char const *const *pcpcc;
   char **ppc;
@@ -1681,8 +1681,9 @@ AC_DEFUN([AC_C_CONST],
   ++pcpcc;
   ppc = (char**) pcpcc;
   pcpcc = (char const *const *) ppc;
-  { /* SCO 3.2v4 cc rejects this.  */
-    char *t;
+  { /* SCO 3.2v4 cc rejects this sort of thing.  */
+    char tx;
+    char *t = &tx;
     char const *s = 0 ? (char *) 0 : (char const *) 0;

     *t++ = 0;
@@ -1698,10 +1699,10 @@ AC_DEFUN([AC_C_CONST],
     iptr p = 0;
     ++p;
   }
-  { /* AIX XL C 1.02.0.0 rejects this saying
+  { /* AIX XL C 1.02.0.0 rejects this sort of thing, saying
        "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */
-    struct s { int j; const int *ap[3]; };
-    struct s *b; b->j = 5;
+    struct s { int j; const int *ap[3]; } bx;
+    struct s *b = &bx; b->j = 5;
   }
   { /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */
     const int foo = 10;



reply via email to

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