[radvd-devel-l] AC_C_CONST m4 macro misbehaves with GCC resulting in stripping const

Petr Pisar ppisar at redhat.com
Tue Jun 19 10:22:47 EDT 2012


Hello,

while checking compiler warnigs ('CFLAGS=-O0 -Werror -Wall'), I found this
issue:

util.c: In function ‘print_addr’:
util.c:42:6: error: assignment discards ‘const’ qualifier from pointer target
type [-Werror]

The code is:

    const char *res;

    /* XXX: overflows 'str' if it isn't big enough */
42: res = inet_ntop(AF_INET6, (void *)addr, str, INET6_ADDRSTRLEN);

and the warning is emitted when assigning inet_ntop() return value to the
`res' variable.

The code is fine. The problems is in autoconf macro AC_C_CONST. It concludes
my compiler (GCC 4.6.3) does not support `const' qualifier properly and this
redefines the symbol to empty string, config.h:

  /* Define to empty if `const' does not conform to ANSI C. */
  #define const /**/

Searching web finds the problem is used to being solved by removing this
macro from configure.ac. The only attempt to fix the autoconf macro I found
(http://lists.gnu.org/archive/html/bug-autoconf/2011-09/msg00002.html) has
never gotten into upstream.

Do you want to remove it too? Otherwise all the const qualifiers gets lost
from your code effectively.

-- Petr
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 230 bytes
Desc: not available
URL: <http://lists.litech.org/pipermail/radvd-devel-l/attachments/20120619/cde779fd/attachment.pgp>


More information about the radvd-devel-l mailing list