[cfe-dev] Strange AST behavior with C++ casts

Sebastian Redl sebastian.redl at getdesigned.at
Tue Oct 4 02:48:39 PDT 2011

On 03.10.2011 19:37, John McCall wrote:
> On Oct 3, 2011, at 10:17 AM, Nicola Gigante wrote:
>> So, to recap:
>> - Have I understood correctly why this issue happens?
> Well, it's not accidental.  C's semantics are easy enough to check with a function that, logically, just computes a cast kind for the conversion, adding extra implicit casts in the rare cases where they're required.  C++'s semantics aren't that simple;  we can generate a lot of expressions for one of those casts, and the outermost node is not always a cast at all.
To give you one example: a cast to a class type using a user-defined 
conversion constructor will be a noop cast expression containing a 
CXXConstructExpr (or something similar). There is not really a good way 
you can embed that functionality in the cast expression itself.


More information about the cfe-dev mailing list