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
On Mon, May 06, 2002 at 10:42:08AM +0100, Joseph S. Myers wrote:
> On Mon, 6 May 2002, Aldy Hernandez wrote:
>
> > for example,
> >
> > int foo (unsigned int blah) { }
> >
> > accepts foo(31) as well as foo(31U).
>
> It also accepts foo(31LL) and other such implicitly convertible types, if
> the prototype is in scope. Or are you referring to the special case where
> a prototype isn't in scope (and for variable arguments), and
> signed/unsigned can be mixed provided the value is representable in both
> types?
i'm not sure i follow you.
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*.
> > can i "fix" __builtin_types_compatible_p?
>
> The types aren't compatible. (Pointers to them aren't even implictly
> convertible, though you'll need -pedantic to get a warning about that.)
perhaps we should return true, like i suggest, but warn with -pedantic??
aldy