Improper implicit pointer cast in AST

Abramo Bagnara abramo.bagnara at bugseng.com
Thu Sep 4 06:23:40 PDT 2014


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

BTW: this violates C++11 5.9p2 where it is said that

"Otherwise, the composite pointer type is a pointer type similar (4.4)
to the type of one of the operands, with a cv-qualification signature
(4.4) that is the union of the cv-qualification signatures of the
operand types."

> 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?
> 


-- 
Abramo Bagnara

BUGSENG srl - http://bugseng.com
mailto:abramo.bagnara at bugseng.com



More information about the cfe-commits mailing list