Re: strict aliasing (again)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



* Andrew Haley <aph@xxxxxxxxxx> [2008-12-02 11:52:00 +0000]:

> >     struct Vector3 {
> >         float x, y, z;
> >         float & operator[] (int i) { return *(&x+i); }
> 
> This can't work.  Well, unless i happens to be zero.

by "cant work" - what conditions do you have in mind? whole code is
compiled with -fno-strict-aliasing -O1 and this works. if it was not,
it would be spotted long time ago.

> What *are* you trying to do?

i am actually trying to fix this mess that one guy made long time ago
(on windows). there are plenty of casts from anything to anything and
then dereferencing these anythings.

but there is an awful lot of code *depending* on this so i cannot afford
complete rewrite i am afraid. so i am trying to find easier ways around
first.

>  There are straightforward ways to do this such as
>   struct Vector3 {
>       float d[3];
>       float & x() { return d[0]; }

the problem is that users are accessing it by v.x, not only v.x() or
v[0]. to fix that it will be hell, but possibly worth it.

many thanks,
mojmir

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux