> The equivalent of the offending line would be
> 
> foo((double *)(void *) &j);
> 
> since any access through a void pointer CAN change the value.

'(double *)(void *)' does not keep some sort of remnant of the 'void *'. The 
final cast renders the end-result a 'double *' and negates the 'void *'. You 
cannot cast 'through' another type to get some remnant of that type. (In old C.)

This is a very common 'fix' for aliasing bugs that does not work.
 
> Thank you for showing me why I should always include
> -fno-strict-aliasing in my gcc commandlines.  It's broken, horribly.

Actually, what's broken is not allowing a large class of useful optimizations 
for the occasional code that chooses to invoke undefined behavior. That said, I 
do exactly what you suggest. I've had too much old code break horribly and 
subtly to find the optimizations worth the risk. So my 'official' position is 
not the same as my personal position.

C has unions and 'char *', and more recently 'void *'. However, you cannot 
invoke them and then discard them and expect some 'remnant'. An object is the 
type of the last cast.

I'm going to go dig out my standard. Maybe I'm misremembering.

DS


______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
Development Mailing List                       openssl-dev@openssl.org
Automated List Manager                           [EMAIL PROTECTED]

Reply via email to