This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: generalized lvalues


On Fri, Nov 19, 2004 at 05:29:27PM -0800, Ziemowit Laski wrote:
> What I was hoping for is that we can turn
> 
>         (cast)expr = ...
>         *(cast)expr)++
> into
> 
>         *((cast *)&expr) = ...
>         *((cast *)&expr)++
> 
> when -fassign-to-cast is specified.

So, it appears that you want to turn (cast)expr into *((cast *)&expr).
You still have the issue with C++ overloading; since it is an lvalue,
if you have

void func(cast&);
void func(const cast&);

then

func((cast)expr) will call the wrong function, because with your rule,
func(cast&) gets called, while with the ISO C++ rule, func(const cast&)
gets called.

Now, you could get around this if you can specify a rule that explains
which casts get transformed and which don't.  This might be doable.

Also, if cast and typeof(expr) are not compatible types by the aliasing
rules of C, and the casted expression is written to, then the resulting
code may be mis-optimized unless the user also specifies
-fno-strict-alias.

I'd rather see Objective-C/C++ written in such a way that they don't
rely on writing to casts, though.




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]