[cfe-commits] Better const_cast support

Eli Friedman eli.friedman at gmail.com
Fri Sep 26 16:40:45 PDT 2008


On Fri, Sep 26, 2008 at 3:10 PM, Sebastian Redl
<sebastian.redl at getdesigned.at> wrote:
> Updated patch. Supports arrays and function pointers the same way as GCC (as
> near as I can determine).
>
> What it does not support is array decay. This fails:
>
> const int ar[100];
> int *pi = const_cast<int*>(ar);
>
> This is because lvalue-to-rvalue conversion is not performed on the argument
> (would lead to array decay). Is a generic facility for this in the semantic
> checker somewhere? It's really indispensable for C++ semantic checking.
On Fri, Sep 26, 2008 at 3:10 PM, Sebastian Redl
<sebastian.redl at getdesigned.at> wrote:
> What it does not support is array decay. This fails:
>
> const int ar[100];
> int *pi = const_cast<int*>(ar);
>
> This is because lvalue-to-rvalue conversion is not performed on the argument
> (would lead to array decay). Is a generic facility for this in the semantic
> checker somewhere? It's really indispensable for C++ semantic checking.

Sema::DefaultFunctionArrayConversion should do what you want in the
cases where the destination type isn't a reference type.

-Eli



More information about the cfe-commits mailing list