This is the mail archive of the gcc-patches@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]

Re: [PATCH] Fix libstdc++/C++ fallout from RTL alias export


Hi,
> As memcpy is misoptimized I'm leaning towards using uninitialized_copy
> on the members (but I'm not able to get the fancy things right there),
> or simply do
>
>         for (unsigned i = 0; i < sizeof (_Any_data); ++i)
>           std::swap(((char *)__x._M_functor._M_access())[i],
>                     ((char *)_M_functor._M_access())[i]);
>
> that also avoids the temporary object.  There doesn't seem to be
> a uninitalized_swap.
>   
Doesn't exist, for sure. Looks rather clean. I have yet to convince
myself that it's completely safe, however (you are accessing each char
of the current dynamic type as void*, is that ok?), I was thinking more
along the lines of figuring out the right _Tp to pass to the templatized
_M_access and issue just one call for the entire stored object. Can be
tricky...

...anyway, for 4.5.0, maybe the standard approach with memcpy is safer
and very simple to implement in the library. Shouldn't we fix 42834
anyway? I seem to understand that *all* our users having aliasing
problems are told to use memcpy and if it doesn't work well for such a
common little buffer like _Any_data, I'm really scared!

Paolo.


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