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

Vincent Lefevre vincent at vinc17.net
Wed Jul 3 13:12:12 UTC 2019

On 2019-07-03 14:40:14 +0200, Torbjorn Granlund wrote:
> Cool, this might be a useful GNU extension!
> But I shrudder to see that you Vincent of all people seem to suggest
> that we stray away from the Holy Standard!  :-D

Some GNU extensions, like __builtin_unreachable() are fine with
the ISO C standard. Other extensions, like empty translation units
(which isn't even a GNU extension, at least not currently, just
undefined behavior with GCC, which may appear to work by chance),
are not.


zira:~> cat foo.c
#ifndef D

int foo (int i)
  if (i)
  return i + 1;


zira:~> gcc -std=c11 -pedantic-errors -c foo.c
zira:~> gcc -std=c11 -pedantic-errors -c foo.c -DD
foo.c:10: error: ISO C forbids an empty translation unit [-Wpedantic]

In any case, any GNU extension should be optional.

> The disputed current GMP code does not get executed for values where
> undefined behaviour is triggered, and it gives consistently great code
> for old and new gcc as well as clang.

Even under MS windows? According to my tests with the sizes used on
WIN64, the cast yields a 64-bit multiplication by a 64-bit constant
with GCC, while one gets a 32-bit multiplication by a 32-bit constant
without the cast.

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