> Le 23 oct. 2019 à 07:33, Akim Demaille <a...@lrde.epita.fr> a écrit :
> 
>> Le 22 oct. 2019 à 20:10, Paul Eggert <egg...@cs.ucla.edu> a écrit :
>> 
>> On 10/21/19 2:07 AM, Akim Demaille wrote:
>> 
> 
>> GCC 9 should have the necessary primitives to bypass the code eliciting the 
>> warnings you mentioned; besides, recent GCCs are better at avoiding false 
>> alarms with options like -Wtype-limits. I don't see why macOS GCC 9 would 
>> differ from GNU/Linux GCC 9 in this area.
> 
> I know.  That's why I wrote
> 
>>> Except that on this mac GCC 7 to 9 shows the warning.  I don't understand 
>>> [why] there's a difference with GNU/Linux.

So I had a closer look at intprops.h, and the problem is actually coming from 
limits.h (the system's one, not gnulib's):

$ cat intprops.h
#include <limits.h>
$ gcc-mp-9  -Wextra -E intprops.h -dM | grep _has_buil
#define __has_builtin(x) 0

which ruins all your efforts on has_builtin in intprops.h:

/* If the compiler lacks __has_builtin, define it well enough for this
   source file only.  */
#ifndef __has_builtin
# define __has_builtin(x) _GL_HAS_##x
# if 5 <= __GNUC__ && !defined __ICC
#  define _GL_HAS___builtin_add_overflow 1
# else
#  define _GL_HAS___builtin_add_overflow 0
# endif
# define _GL_TEMPDEF___has_builtin
#endif

It seems to come from

/opt/local/lib/gcc9/gcc/x86_64-apple-darwin18/9.2.0/include-fixed/os/base.h

which starts with

#include <sys/cdefs.h>

#ifndef __has_builtin
#define __has_builtin(x) 0
#endif
#ifndef __has_include
#define __has_include(x) 0
#endif
#ifndef __has_feature
#define __has_feature(x) 0
#endif
#ifndef __has_attribute
#define __has_attribute(x) 0
#endif
#ifndef __has_extension
#define __has_extension(x) 0
#endif
#ifndef __has_extension
#define __has_extension(x) 0
#endif

which seems consistent with the fact that GCC 9 does not support __has_builtin 
(contrary to what I believed)

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66970

I guess that since macOS's "native" compiler is Clang, which does support 
__has_builtin, GCC folks want to emulate that compiler.  By emasculating theirs.

Unfortunately on __has_builtin(__has_builtin) clang returns 0.

Reply via email to