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

Reuben Hawkins reubenhwk at gmail.com
Tue Jun 19 21:08:13 EDT 2012


On Tue, Jun 19, 2012 at 7:22 AM, Petr Pisar <ppisar at redhat.com> wrote:
> 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
>
> --
> radvd-devel-l mailing list  :  radvd-devel-l at litech.org
> http://lists.litech.org/listinfo/radvd-devel-l



I removed AC_C_CONST.



More information about the radvd-devel-l mailing list