This is the mail archive of the gcc-help@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: Any way to locally apply no-strict-alias?


John Fine wrote:
> I have a very large module, which contains a few places where a pointer
> is cast based on a templated data type.
> 
> Typically a pointer is created using a templated type, then copied as a
> void*, then used as the templated type.  In one of those places, the
> optimizer removes the copy step, which is correct behavior for the
> optimizer under strict aliasing, but of course incorrect for the program.

I don't really get this.

You are allowed to take a pointer, copy it as a void *, and copy it
back to the same type and dereference it.  If the compiler removes
the copy step, then the compiler is broken.  If your code accesses
the object via an incompatible type, then your code is broken.

Confused,
Andrew.


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