autoconf-patches
[Top][All Lists]
Advanced

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

Re: AC_CHECK_SIZEOF([int *]) is error in autoconf-2.66


From: Ralf Wildenhues
Subject: Re: AC_CHECK_SIZEOF([int *]) is error in autoconf-2.66
Date: Tue, 6 Jul 2010 22:26:35 +0200
User-agent: Mutt/1.5.20 (2010-04-22)

Hello,

> On Sat, 3 Jul 2010 18:28:27 -0400 (EDT) Eric Blake wrote:
> > Indeed, I spent a bit more time, and reproduced your follow-on
> > issue.  Here's the complete patch (the same as before in types.m4,
> > plus a new patch in m4sh.m4), which should resolve the issue.

Patch here.  Eric, I'm not quite sure why you added the + to the
_AS_TR_SH case.  Can you explain, so I can add testsuite coverage?
Thanks.

More generaly, I'm not sure whether we should be testing all sorts of
other characters, or what tests I should be adding to tests/m4sh.at:
AS_TR_SH and AS_TR_CPP to expose these issues.  Did your patch series
intend to have any user-visible semantic impact at all (for existing
prior defined semantics)?

Also, there are a couple of things not dealt with in this patch, but
they are *not* regressions and rather straight-forwardly worked around,
too.  This change:

| diff --git a/tests/semantics.at b/tests/semantics.at
| index 48136cd..0af9c13 100644
| --- a/tests/semantics.at
| +++ b/tests/semantics.at
| @@ -349,11 +349,14 @@ AC_CHECK_ALIGNOF(charcharchar)
|  AT_CHECK_MACRO_CROSS([AC_CHECK_ALIGNOF struct],
|  [[AC_CHECK_ALIGNOF([struct { char c; }])
|  AC_CHECK_ALIGNOF([struct nosuchstruct])
| +AC_CHECK_ALIGNOF([[struct { int *p; double x[2]; }]])
|  ]],
|  [AT_CHECK([[grep "#define ALIGNOF_STRUCT___CHAR_C___ [1-9]" config.h]],
|        0, ignore)
|  AT_CHECK([[grep "#define ALIGNOF_STRUCT_NOSUCHSTRUCT 0" config.h]],
|        0, ignore)
| +AT_CHECK([[grep "#define ALIGNOF_STRUCT___INT_PP__DOUBLE_X2___ [1-9]" 
config.h]],
| +      0, ignore)
|  ])
|  
|  # AC_CHECK_SIZEOF
| 

exposes two issues: the translation from type to define name omits the
brackets [ ] from an array declaration.  Also, it produces this in
config.h:

  /* The normal alignment of `[struct { int *p; double x[2]; }]', in bytes. */
  #define ALIGNOF_STRUCT___INT_PP__DOUBLE_X2___ 
$ac_cv_alignof_struct___int_pp__double_x2___

where the RHS of the define is wrongly not expanded, and the comment
contains spurious outer brackets.

2.65 already failed earlier with above change:

| 303. semantics.at:318: testing ...
| ../../autoconf/tests/semantics.at:318: autoconf --force -W obsolete
| --- /dev/null   2009-07-18 07:45:28.000000000 +0200
| +++ /tmp/build/tests/testsuite.dir/at-groups/303/stderr     2010-07-06 
11:20:58.000000000 +0200
| @@ -0,0 +1,4 @@
| +configure.ac:6: error: AC_CHECK_ALIGNOF: requires literal arguments
| +../../../autoconf/lib/autoconf/types.m4:788: AC_CHECK_ALIGNOF is expanded 
from...
| +configure.ac:6: the top level
| +autom4te: /usr/bin/m4 failed with exit status: 1
| ../../autoconf/tests/semantics.at:318: exit code was 1, expected 0
| 303. semantics.at:318: 303. AC_CHECK_ALIGNOF struct (semantics.at:318): 
FAILED (semantics.at:318)

so there is little to actually worry about for 2.67 IMVHO.

OK to commit?

Thanks,
Ralf

2010-07-06  Eric Blake  <address@hidden>
        and Ralf Wildenhues  <address@hidden>

        Fix regression of AC_CHECK_SIZEOF on pointer types.
        * lib/autoconf/types.m4 (AC_CHECK_SIZEOF): Translate `*' to `p'
        when checking literal-ness of the type, for pointer types.
        * lib/m4sugar/m4sh.m4 (_AS_TR_SH): Also translate `+' and `*'
        to `_'.
        (_AS_TR_CPP): Also translate `*' to `_'.
        * tests/semantics.at (AC_CHECK_ALIGNOF struct): When checking
        for numeric answer, be sure to not allow variable references.
        (AC_CHECK_SIZEOF struct): Likewise.  Also, test the
        AC_CHECK_SIZEOF([int *]) example from the manual.
        * doc/autoconf.texi (Generic Compiler Characteristics): Add
        example marker.
        * NEWS: Update.
        Reports by Nishio Futoshi and Roberto Bagnara.

diff --git a/NEWS b/NEWS
index 7282697..6c98c23 100644
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,8 @@ GNU Autoconf NEWS - User visible changes.
 
 * Noteworthy changes in release ?.? (????-??-??) [?]
 
+** AC_CHECK_SIZEOF of a pointer type works again.  Regression introduced in
+   2.66.
 
 * Major changes in Autoconf 2.66 (2010-07-02) [stable]
   Released by Eric Blake, based on git versions 2.65.*.
diff --git a/doc/autoconf.texi b/doc/autoconf.texi
index 0c106c7..e9fcc70 100644
--- a/doc/autoconf.texi
+++ b/doc/autoconf.texi
@@ -6956,6 +6956,7 @@ argument was used when cross-compiling.
 For example, the call
 
 @example
address@hidden If you change this example, adjust 
tests/semantics.at:AC_F77_DUMMY_MAIN usage.
 AC_CHECK_SIZEOF([int *])
 @end example
 
diff --git a/lib/autoconf/types.m4 b/lib/autoconf/types.m4
index ee07148..9f482da 100644
--- a/lib/autoconf/types.m4
+++ b/lib/autoconf/types.m4
@@ -763,7 +763,7 @@ Remove this warning and the `AC_CACHE_CHECK' when you 
adjust the code.])
 # AC_CHECK_SIZEOF(TYPE, [IGNORED], [INCLUDES = DEFAULT-INCLUDES])
 # ---------------------------------------------------------------
 AC_DEFUN([AC_CHECK_SIZEOF],
-[AS_LITERAL_IF([$1], [],
+[AS_LITERAL_IF(m4_translit([[$1]], [*], [p]), [],
               [m4_fatal([$0: requires literal arguments])])]dnl
 [# The cast to long int works around a bug in the HP C Compiler
 # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
diff --git a/lib/m4sugar/m4sh.m4 b/lib/m4sugar/m4sh.m4
index e1d03d9..051107a 100644
--- a/lib/m4sugar/m4sh.m4
+++ b/lib/m4sugar/m4sh.m4
@@ -1779,7 +1779,7 @@ m4_defun_init([AS_TR_SH],
 [_$0(m4_expand([$1]))])
 
 m4_define([_AS_TR_SH],
-[_AS_LITERAL_IF([$1], [         ][
+[_AS_LITERAL_IF([$1], [*+][     ][
 ])([], [$0_INDIR], [$0_LITERAL])([$1])])
 
 m4_define([_AS_TR_SH_LITERAL],
@@ -1812,7 +1812,7 @@ m4_defun_init([AS_TR_CPP],
 [_$0(m4_expand([$1]))])
 
 m4_define([_AS_TR_CPP],
-[_AS_LITERAL_IF([$1], [         ][
+[_AS_LITERAL_IF([$1], [*][      ][
 ])([], [$0_INDIR], [$0_LITERAL])([$1])])
 
 m4_define([_AS_TR_CPP_LITERAL],
diff --git a/tests/semantics.at b/tests/semantics.at
index b703fd4..48136cd 100644
--- a/tests/semantics.at
+++ b/tests/semantics.at
@@ -350,7 +350,7 @@ AT_CHECK_MACRO_CROSS([AC_CHECK_ALIGNOF struct],
 [[AC_CHECK_ALIGNOF([struct { char c; }])
 AC_CHECK_ALIGNOF([struct nosuchstruct])
 ]],
-[AT_CHECK([[grep "#define ALIGNOF_STRUCT___CHAR_C___ [^0]" config.h]],
+[AT_CHECK([[grep "#define ALIGNOF_STRUCT___CHAR_C___ [1-9]" config.h]],
         0, ignore)
 AT_CHECK([[grep "#define ALIGNOF_STRUCT_NOSUCHSTRUCT 0" config.h]],
         0, ignore)
@@ -379,13 +379,17 @@ AT_CHECK_MACRO_CROSS([AC_CHECK_SIZEOF struct],
 AC_CHECK_SIZEOF([struct x], [], [struct x { char c; int x; };])
 AC_CHECK_SIZEOF([const struct x], [], [struct x { const char *p; int x; };])
 AC_CHECK_SIZEOF([struct nosuchstruct])
+# Taken from autoconf.texi:Generic Compiler Characteristics.
+AC_CHECK_SIZEOF([int *])
 ]],
-[AT_CHECK([[grep "#define SIZEOF_STRUCT_X [^0]" config.h]],
+[AT_CHECK([[grep "#define SIZEOF_STRUCT_X [1-9]" config.h]],
         0, ignore)
-AT_CHECK([[grep "#define SIZEOF_CONST_STRUCT_X [^0]" config.h]],
+AT_CHECK([[grep "#define SIZEOF_CONST_STRUCT_X [1-9]" config.h]],
         0, ignore)
 AT_CHECK([[grep "#define SIZEOF_STRUCT_NOSUCHSTRUCT 0" config.h]],
         0, ignore)
+AT_CHECK([[grep "#define SIZEOF_INT_P [1-9]" config.h]],
+        0, ignore)
 ])
 
 



reply via email to

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