------- Comment #35 from ebotcazou at gcc dot gnu dot org  2007-03-06 06:59 
-------
> The problem looks like a bug in GCC's optimisation in 4.1.1 - for the
> following code:
> 
> 152             while (--delete_count>=0) {
> 153                     zval *q = *(zval **)(--p);
> 154                     *p = NULL;
> (gdb) l
> 155                     zval_ptr_dtor(&q);
> 156             }
> 157             EG(argument_stack).top_element = p;
> 
> ('p' is declared as void **)

Thanks for investigating.  The above code is illegal as per the ISO C standard
because it violates the type-based aliasing rules: you're not allowed to read
a void** object through a zval** lvalue, so the code is equivalent to

152             while (--delete_count>=0) {
                        --p;
                        zval *q = NULL;
                        *p = NULL;

155                     zval_ptr_dtor(&q);
156             }
157             EG(argument_stack).top_element = p;

and the compiler correctly optimizes it.  You must compile such code with
-fno-strict-aliasing (see the entry for this option in the manual).


-- 

ebotcazou at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |UNCONFIRMED
         Resolution|FIXED                       |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30819

Reply via email to