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

Richard Guenther <rguenth at gcc dot gnu.org> changed:

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

--- Comment #2 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-07-28 
09:55:58 UTC ---
    char *same_data = s.ptr + (data - s.ptr);
    same_data[0] = 1;

same_data now points to s.ptr plus some offset that isn't computed in any
standard compliant way.  As s.ptr is NULL the store is dead.

With

  char *same_data = (char *)((uintptr_t) s.ptr + (uintptr_t) data - (uintptr_t)
s.ptr));

you would get the correct answer, avoiding all the undefinedness in your code.

Reply via email to