This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: rfc: __builtin_types_compatible_p and unsigned literals
- From: "Joseph S. Myers" <jsm28 at cam dot ac dot uk>
- To: Aldy Hernandez <aldyh at redhat dot com>
- Cc: <gcc at gcc dot gnu dot org>
- Date: Mon, 6 May 2002 12:25:35 +0100 (BST)
- Subject: Re: rfc: __builtin_types_compatible_p and unsigned literals
On Mon, 6 May 2002, Aldy Hernandez wrote:
> what i'm referring to, is that i believe the following should all
> return true:
>
> __builtin_types_compatible_p(int, typeof(1))
> __builtin_types_compatible_p(int, typeof(1L))
> __builtin_types_compatible_p(int, typeof(1LL))
> __builtin_types_compatible_p(int, typeof(1U))
> __builtin_types_compatible_p(int, typeof(1ULL))
> __builtin_types_compatible_p(int, typeof(1UL))
> etc
>
> whereas now, these return false. they should return true-- after all,
> they are *compatible*.
They're not compatible. Compatibility is defined in C99 subclause 6.2.7.
They can be implicitly converted in a function call, by 6.5.2.2#2, but
that's because one of the circumstances listed in 6.5.16.1#1 (which are
asymmetric - you can assign char * to const char * but not the other way
round - whereas compatibility is symmetric) applies.
float, double and long double are all incompatible - and all need to be
distinguished for <tgmath.h> and such purposes for which
__builtin_types_compatible_p was designed - though they can be assigned to
each other.
--
Joseph S. Myers
jsm28@cam.ac.uk