Re: Re: gcc 3.3 warnings about strict-aliasing rules
| From: | Stefan Roehrich | Date: | Tue, 26 Aug 2003 09:02:28 +0000 |
| Subject: | Re: Re: gcc 3.3 warnings about strict-aliasing rules | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-4194@lists.php.net to get a copy of this message | ||
On 2003-08-25 14:54:48, Ard Biesheuvel wrote:
> Casting to void* instead of void** cures the problem. As the cast
Yes, but why?
> I would consider it a justified change. I don't think there will be
> consequences for the validity of the optimization.
I don't know if with some optimizations void* or zval pointers need
special alignment.
> Code will have to be changed regardless, as it's not the function
> invocation but the cast itself that triggers the warning.
Yes, or we would be on the safe side if we compile with
-fno-strict-aliasing, then gcc doesn't do such expression based
optimizations. Or (as I have seen on some patches for other projects
after a search for the gcc warning message) we could change the zval**
data to something like this:
union {
zval **zval;
void *ptr;
} data;
call zend_hash_find(..., &data.ptr) and after this use
data.zval. Access via unions is allowed because then the data must be
correctly aligned for both types.
The gcc generated code for this variant only uses some other
registers, otherwise it seems similar.
Stefan
--
Stefan Röhrich stefan@roehri.ch, sr@linux.de
http://www.roehri.ch/~sr/