ISO C forbids an empty translation unit again

Dennis Clarke dclarke at blastwave.org
Mon Sep 2 21:48:10 UTC 2019


Same as last year :

     https://gmplib.org/list-archives/gmp-bugs/2018-February/004305.html

This one pops up now and again if I go with LLVM/Clang on FreeBSD and
with really strict CFLAGS.  So in a few files I had to drop in a silly
typedef.

vesta_$
vesta_$ diff -u ./printf/obprintf.c.orig ./printf/obprintf.c
--- ./printf/obprintf.c.orig    2016-12-16 15:45:27.000000000 +0000
+++ ./printf/obprintf.c 2019-09-01 05:59:47.184923000 +0000
@@ -57,3 +57,5 @@
  }

  #endif /* HAVE_OBSTACK_VPRINTF */
+
+typedef unsigned int foo_boo_doo;



vesta_$
vesta_$ diff -u ./printf/obprntffuns.c.orig ./printf/obprntffuns.c
--- ./printf/obprntffuns.c.orig 2016-12-16 15:45:27.000000000 +0000
+++ ./printf/obprntffuns.c      2019-09-01 06:02:16.768498000 +0000
@@ -70,3 +70,6 @@
  };

  #endif /* HAVE_OBSTACK_VPRINTF */
+
+typedef unsigned int foo_boo_doo;
+



vesta_$ diff -u ./printf/obvprintf.c.orig ./printf/obvprintf.c
--- ./printf/obvprintf.c.orig   2016-12-16 15:45:27.000000000 +0000
+++ ./printf/obvprintf.c        2019-09-01 06:01:06.151394000 +0000
@@ -50,3 +50,6 @@
  }

  #endif /* HAVE_OBSTACK_VPRINTF */
+
+typedef unsigned int foo_boo_doo;
+



vesta_$ diff -u ./printf/repl-vsnprintf.c.orig ./printf/repl-vsnprintf.c
--- ./printf/repl-vsnprintf.c.orig      2016-12-16 15:45:27.000000000 +0000
+++ ./printf/repl-vsnprintf.c   2019-09-01 06:03:11.942015000 +0000
@@ -394,3 +394,6 @@
  }

  #endif /* ! HAVE_VSNPRINTF */
+
+typedef unsigned int foo_boo_doo;
+


Also in the tests I saw :


/usr/bin/cc -DHAVE_CONFIG_H -I. -I../..  -I../.. -I../../tests 
-D_TS_ERRNO -D_POSIX_PTHREAD_SEMANTICS -D_LARGEFILE64_SOURCE  -pedantic 
-pedantic-errors -fshow-column -fshow-source-location 
-fno-color-diagnostics -fdiagnostics-format=vi -fno-elide-type 
-fsanitize=undefined -fsanitize-stats -fno-fast-math 
-ftls-model=global-dynamic -g -m64 -std=c99 -O0 -c -o t-get_str.o 
t-get_str.c
t-get_str.c +68:30: error: format specifies type 'void *' but the 
argument has type 'char *' [-Werror,-Wformat-pedantic]
       printf ("  got  %p\n", ret);
                       ~~     ^~~
                       %s
t-get_str.c +69:30: error: format specifies type 'void *' but the 
argument has type 'const char *' [-Werror,-Wformat-pedantic]
       printf ("  want %p\n", want);
                       ~~     ^~~~
                       %s
2 errors generated.
*** Error code 1


I know that is silly pedantic so I tossed in a (void *) cast and life
goes onwards.


vesta_$ diff -u ./tests/mpq/t-get_str.c.orig ./tests/mpq/t-get_str.c
--- ./tests/mpq/t-get_str.c.orig        2016-12-16 15:45:27.000000000 +0000
+++ ./tests/mpq/t-get_str.c     2019-09-01 18:59:10.238243000 +0000
@@ -65,8 +65,8 @@
      {
        printf ("mpq_get_str wrong return value (passing non-NULL)\n");
        printf ("  base %d\n", base);
-      printf ("  got  %p\n", ret);
-      printf ("  want %p\n", want);
+      printf ("  got  %p\n", (void *)ret);
+      printf ("  want %p\n", (void *)want);
        abort ();
      }
    if (strcmp (str, want) != 0)
vesta_$


I don't see these complaints with Oracle Studio 12.6 nor with gcc and
-std=iso9899:1999 and -pedantic etc.  Seems LLVM/Clang is very picky
when you ask it to be picky.  Ultimately everything just works but
with LLVM/Clang it needed a little help.

vesta_$ cc --version
FreeBSD clang version 6.0.1 (tags/RELEASE_601/final 335540) (based on 
LLVM 6.0.1)
Target: x86_64-unknown-freebsd12.0
Thread model: posix
InstalledDir: /usr/bin
vesta_$


-- 
Dennis Clarke
RISC-V/SPARC/PPC/ARM/CISC
UNIX and Linux spoken
GreyBeard and suspenders optional


More information about the gmp-bugs mailing list