This is the mail archive of the
mailing list for the GCC project.
Re: builtin_types_compatible_p and const
- From: "Joseph S. Myers" <jsm28 at cam dot ac dot uk>
- To: Aldy Hernandez <aldyh at redhat dot com>
- Cc: Daniel Egger <degger at fhm dot edu>, GCC Developer Mailinglist <gcc at gcc dot gnu dot org>
- Date: Tue, 26 Feb 2002 09:24:08 +0000 (GMT)
- Subject: Re: builtin_types_compatible_p and const
On Tue, 26 Feb 2002, Aldy Hernandez wrote:
> >> first, vec_lvsl accepts "char *" not "const char *", so you'll
> >> have to cast.
> > That's about the most annoying thing. What's wrong about loading
> > from a constant address?
> i agree, let's summon the expert again...
> joseph, i agree with daniel. the code below should compile, but
> x and y are not compatible according to the builtin. are there
> any objections to making a patch to fix this?
> const char *x;
> char *y;
> int foo[__builtin_types_compatible_p (__typeof(x), __typeof(y)) == 1 ?
> 1 : -1];
If vec_lvsl accepts "char *" rather than "const char *", presumably it
modifies what's pointed to by its argument (else why wasn't it specified
to use const, unless the interface predates ANSI C89)?
Again, check *x and *y, or explicitly enumerate the variants in the
header. Or arrange for some built-in function to check for assignability
(which is not the same as compatibility) - in this case, that the target
type of the argument has fewer qualifiers than that of the formal
parameter, so you avoid allowing volatile there - but if you're passing
const, then vec_lvsl should be prototyped to accept it.
Joseph S. Myers