This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug tree-optimization/38835] field-insensitive PTA causes libstdc++ miscompiles



------- Comment #3 from rguenther at suse dot de  2009-01-16 18:27 -------
Subject: Re:  field-insensitive PTA causes
 libstdc++ miscompiles

On Fri, 16 Jan 2009, pinskia at gcc dot gnu dot org wrote:

> ------- Comment #2 from pinskia at gcc dot gnu dot org  2009-01-16 18:22 -------
>           return reinterpret_cast<_Tp*>(reinterpret_cast<_UIntPtrType>(this)
>                                         + _M_diff);
> 
> 
>    (const struct _Fwd_list_node_base *) this p+ (long unsigned int) ((const
> struct _Relative_pointer_impl *) this)->_M_diff
> 
> 
> That seems fine.  In fact If we are failing because of aliasing issues, then we
> have a bigger issue really because the code could have been written as:
>           return reinterpret_cast<_Tp*>(reinterpret_cast<char*>(this) +
> _M_diff);
> 
> And still be defined so I don't think this is really PR 36227.

No, char * is not allowed to change objects either.  What the above code
does is use the pointer -> intptr -> pointer rule by storing a pointer
as a relative offset to the store, like so:

  void *p;
  intptr_t iptr = (intptr_t)&iptr - (intptr_t)p;

and reconstructing p via

  (void *)((intptr_t)&iptr + iptr);

which is perfectly valid, but we break that because we fold the latter
to (void *)(&iptr + iptr) which is of course invalid.

Richard.


-- 


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]