minor noises made by gcc and -std=iso9899:1999 with -Wall -pedantic -Wextra -pedantic-errors

Vincent Lefevre vincent at vinc17.net
Mon Jul 1 12:09:29 UTC 2019


On 2019-06-29 20:32:07 -0400, Dennis Clarke wrote:
> Of course with silly strict C99 I end up with :
> 
> libtool: compile:  /usr/bin/gcc -DHAVE_CONFIG_H -I. -I.. -D__GMP_WITHIN_GMP
> -I.. -I/opt/bw/include -D_POSIX_PTHREAD_SEMANTICS -D_TS_ERRNO
> -std=iso9899:1999 -m32 -g -Wall -pedantic -Wextra -pedantic-errors
> -march=i686 -mtune=i686 -Wl,-rpath=/opt/bw/lib,--enable-new-dtags
> -fno-builtin -malign-double -mpc80 -D_LARGEFILE64_SOURCE -c vsprintf.c -o
> vsprintf.o >/dev/null 2>&1
> /bin/bash ../libtool  --tag=CC   --mode=compile /usr/bin/gcc -DHAVE_CONFIG_H
> -I. -I..  -D__GMP_WITHIN_GMP -I.. -I/opt/bw/include
> -D_POSIX_PTHREAD_SEMANTICS -D_TS_ERRNO  -std=iso9899:1999 -m32 -g -Wall
> -pedantic -Wextra -pedantic-errors -march=i686 -mtune=i686
> -Wl,-rpath=/opt/bw/lib,--enable-new-dtags -fno-builtin -malign-double -mpc80
> -D_LARGEFILE64_SOURCE -c -o repl-vsnprintf.lo repl-vsnprintf.c
> libtool: compile:  /usr/bin/gcc -DHAVE_CONFIG_H -I. -I.. -D__GMP_WITHIN_GMP
> -I.. -I/opt/bw/include -D_POSIX_PTHREAD_SEMANTICS -D_TS_ERRNO
> -std=iso9899:1999 -m32 -g -Wall -pedantic -Wextra -pedantic-errors
> -march=i686 -mtune=i686 -Wl,-rpath=/opt/bw/lib,--enable-new-dtags
> -fno-builtin -malign-double -mpc80 -D_LARGEFILE64_SOURCE -c repl-vsnprintf.c
> -fPIC -DPIC -o .libs/repl-vsnprintf.o
> repl-vsnprintf.c:396: error: ISO C forbids an empty translation unit
> [-Wpedantic]
>  #endif /* ! HAVE_VSNPRINTF */
>  make[2]: *** [Makefile:435: repl-vsnprintf.lo] Error 1
> make[2]: Leaving directory
> '/opt/bw/build/gmp-6.1.2_Debian_4.19.0-5-686_i686_via_eden_esther.001/printf'
> make[1]: *** [Makefile:956: all-recursive] Error 1
> make[1]: Leaving directory
> '/opt/bw/build/gmp-6.1.2_Debian_4.19.0-5-686_i686_via_eden_esther.001'
> make: *** [Makefile:775: all] Error 2
> Command exited with non-zero status 2
> 
> Where I know we have seen that before.

MPFR uses in a #else part:

/* Avoid an empty translation unit (see ISO C99, 6.9) */
typedef int foo;

This is rather important, because even if the compiler can generate
code, the behavior of this code is undefined[*] (I don't see why there
would be any issue, but as compilers become more and more complex,
who knows...), thus one might silently get wrong results.

[*] https://stackoverflow.com/a/38442033/3782797

-- 
Vincent Lefèvre <vincent at vinc17.net> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)


More information about the gmp-discuss mailing list