Re: [Bug tree-optimization/38835] field-insensitive PTA causes libstdc++ miscompiles
On Fri, Jan 16, 2009 at 10:37 AM, rguenth at gcc dot gnu dot org wrote: > > > --- Comment #6 from rguenth at gcc dot gnu dot org 2009-01-16 18:37 > --- > Guaranteed by 7.18.1.4. > "These types are optional." :)
[Bug tree-optimization/38835] field-insensitive PTA causes libstdc++ miscompiles
--- Comment #6 from rguenth at gcc dot gnu dot org 2009-01-16 18:37 --- Guaranteed by 7.18.1.4. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38835
[Bug tree-optimization/38835] field-insensitive PTA causes libstdc++ miscompiles
--- Comment #5 from pinskia at gmail dot com 2009-01-16 18:33 --- Subject: Re: field-insensitive PTA causes libstdc++ miscompiles On Fri, Jan 16, 2009 at 10:30 AM, rguenth at gcc dot gnu dot org wrote: > > (void *)((intptr_t)&iptr + (intptr_t)p - (intptr_t)&iptr) > > <==> > > (void *)(intptr_t)p > > which is guaranteed by the std No that is not guaranteed because of: If the result cannot be represented in the integer type, the behavior is undefined. The result need not be in the range of values of any integer type. :). -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38835
Re: [Bug tree-optimization/38835] field-insensitive PTA causes libstdc++ miscompiles
On Fri, Jan 16, 2009 at 10:30 AM, rguenth at gcc dot gnu dot org wrote: > > (void *)((intptr_t)&iptr + (intptr_t)p - (intptr_t)&iptr) > > <==> > > (void *)(intptr_t)p > > which is guaranteed by the std No that is not guaranteed because of: If the result cannot be represented in the integer type, the behavior is undefined. The result need not be in the range of values of any integer type. :).
[Bug tree-optimization/38835] field-insensitive PTA causes libstdc++ miscompiles
--- Comment #4 from rguenth at gcc dot gnu dot org 2009-01-16 18:30 --- void *p; intptr_t iptr = (intptr_t)p - (intptr_t)&iptr; of course. Then this is just (void *)((intptr_t)&iptr + (intptr_t)p - (intptr_t)&iptr) <==> (void *)(intptr_t)p which is guaranteed by the std -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38835
[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(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
[Bug tree-optimization/38835] field-insensitive PTA causes libstdc++ miscompiles
--- 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(this) + _M_diff); And still be defined so I don't think this is really PR 36227. -- pinskia at gcc dot gnu dot org changed: What|Removed |Added BugsThisDependsOn|36227 | http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38835
[Bug tree-optimization/38835] field-insensitive PTA causes libstdc++ miscompiles
--- Comment #1 from rguenth at gcc dot gnu dot org 2009-01-16 13:36 --- Mine. -- rguenth at gcc dot gnu dot org changed: What|Removed |Added AssignedTo|unassigned at gcc dot gnu |rguenth at gcc dot gnu dot |dot org |org Status|UNCONFIRMED |ASSIGNED Ever Confirmed|0 |1 Last reconfirmed|-00-00 00:00:00 |2009-01-16 13:36:04 date|| http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38835