Improper implicit pointer cast in AST

Richard Smith richard at metafoo.co.uk
Sat Sep 6 20:25:18 PDT 2014


On Sat, Sep 6, 2014 at 3:27 AM, Abramo Bagnara <abramo.bagnara at bugseng.com>
wrote:

> Ping
>
> Il 04/09/2014 15:13, Abramo Bagnara ha scritto:
> >
> > For the following source
> >
> > void f() {
> >   char *p;
> >   const char *cp;
> >   p == cp;
> >   p != cp;
> >   p < cp;
> >   p <= cp;
> >   p > cp;
> >   p >= cp;
> >   p - cp;
> > }
> >
> > clang (unexpectedly for me) emits an implicit cast from const char * to
> > char * (i.e. it remove a qualifier) for all the relational and equality
> > operator, but it (expectedly) does not emit one for the subtraction.
> >
> > AFAIK the C standard does not require any conversion for relational and
> > equality operator (just like for subtraction).
> >
> > Do we have a reason to add the implicit casts or it is a bug?
>

It seems like a minor convenience to have an AST invariant that both
operands are of the same type here, but I expect we could remove these
implicit casts without any significant repercussions; I'd be mildly in
favor of doing that since it improves AST fidelity.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140906/3cfbff29/attachment.html>


More information about the cfe-commits mailing list