gcc 3.3 warnings about strict-aliasing rules

From: Date: Sun, 24 Aug 2003 15:16:02 +0000
Subject: gcc 3.3 warnings about strict-aliasing rules
Groups: php.internals 
Request: Send a blank email to internals+get-4158@lists.php.net to get a copy of this message
Hello! If PHP5 cvs is compiled with gcc 3.3 and -Wall, there are warnings about: "dereferencing type-punned pointer will break strict-aliasing rules". E.g. they occur if the last parameter of zend_hash_find is a zval ** and used as zend_hash_find(..., (void **) &data). This warning has to do with the strict aliasing rules (which are turned on by the default -O2), "in particular, an object of one type is assumed never to reside at the same address as an object of a different type, unless the types are almost the same." (from the gcc man page). It can be circumvented by using unions, but this would require changes for nearly every invocation of zend_hash_find() (or should there be a variant of zend_hash_find which takes a zval ** instead of a void **?). Does anybody who knows gcc or the C standard better than I know another solution? Stefan -- Stefan Röhrich stefan@roehri.ch, sr@linux.de http://www.roehri.ch/~sr/

« previous php.internals (#4158) next »