------- Comment #15 from rguenther at suse dot de 2009-09-09 13:37 ------- Subject: Re: forward_list::sort violates strict aliasing rules
On Wed, 9 Sep 2009, paolo dot carlini at oracle dot com wrote: > ------- Comment #14 from paolo dot carlini at oracle dot com 2009-09-09 > 13:18 ------- > (In reply to comment #12) > > I need a reinterpret_cast because a regular static_cast would be an > > access as _Fwd_list_node again - at least the FE (or maybe it is > > fold after all) produces &this->D.1234 in that case which wouldn't fix > > the issue. > > Hey, but this is **incredibly** brittle, long term certainly we don't want a > reinterpret_cast which compiles as a static_cast does but has a different > semantics. We badly need a different solution, long term at least. For now, in > case, a comment 10 lines high and flashing ;) ;) The proper fix is of course to avoid the badly typed this pointer. But I am not sure how to achieve this without sacrifying ABI compatibility (well, I'd make _M_Head a true _Fwd_list_node, wasting space for one _M_value and of course breaking the ABI). Simply moving _M_sort_after to _Fwd_list_node_base might also be possible and would certainly solve the problem in a more elegant way (I didn't try that - libstdc++ is not exactly the area of my expertise, nor is C++ ABI issues). I'll wait for you guys to figure out a proper solution. Richard. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41316