Re: Any way to locally apply no-strict-alias?

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

 



Andrew Haley wrote:
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.


I think the difference between that and what I'm doing is the extra level of indirection.

I write a Datatype* indirectly through a Datatype**. Then I read a void* indirectly through a void** that happens to be the same pointer as that Datatype**.
Next I do the reverse (write through void** to read through Datatype**).

You're saying I can copy a Datatype* to a void* then back to a Datatype* and use it. That wouldn't be a violation of strict aliasing, because it never dereferences two different type pointers to the same address.

I know my code is "broken". I didn't write it and I have no practical way to rewrite it. I'm looking for a local work around to the problem.

I've looked at the generated assembler code and the copy step is optimized out when compiled without -fno-strict-alias and isn't optimized out when compiled with -fno-strict-alias.

[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