Andrew Haley wrote:
We obviously don't want to start having a no-strict-alias attribute for
pointers. I think it's pointless because it would only apply to new
code, and the whole point of no-strict-alias is to make old code work.
I sure disagree with that.
How about making old code repairable.
It would be a monster task to rewrite old code to not need the problem
casts. It is a much more reasonable task to find all the pointers that
are used with problem casts. If you could just tack some attribute onto
the declaration of each such pointer, you could take a giant application
you don't even understand and repair it for this issue in under a day.
I think I've tricked the compiler into generating working code. I don't
think my correction is correct (I think I just confused the optimizer).
But I don't know enough about the exact rules of aliasing to be sure.
I made a union of void* and int*. And my basic pointer now points to
that union instead of being void**.
Then I never use the int* member of the union. What used to directly
use the void** now uses the void* member of the union. What used to use
the Datatye** cast of the void** now uses a Datatype** cast of the
address of the void* member of the union. That still means I'm casting
a void** to a Datatype**, but it seems to have changed the compiler's
understanding of it.