Re: [patch] libstdc++/66017 Avoid bad casts and fix alignment of _Rb_tree_nodelong long::_M_storage

2015-05-27 Thread Jonathan Wakely
On 26/05/15 15:46 +0100, Jonathan Wakely wrote: On 22/05/15 18:48 +0100, Jonathan Wakely wrote: On 22/05/15 16:21 +0100, Jonathan Wakely wrote: On 22/05/15 17:13 +0200, Jakub Jelinek wrote: On Fri, May 22, 2015 at 03:59:47PM +0100, Jonathan Wakely wrote: + alignas(alignof(_Tp2))

Re: [patch] libstdc++/66017 Avoid bad casts and fix alignment of _Rb_tree_nodelong long::_M_storage

2015-05-26 Thread Jonathan Wakely
On 22/05/15 18:48 +0100, Jonathan Wakely wrote: On 22/05/15 16:21 +0100, Jonathan Wakely wrote: On 22/05/15 17:13 +0200, Jakub Jelinek wrote: On Fri, May 22, 2015 at 03:59:47PM +0100, Jonathan Wakely wrote: + alignas(alignof(_Tp2)) unsigned char _M_storage[sizeof(_Tp)]; Is

[patch] libstdc++/66017 Avoid bad casts and fix alignment of _Rb_tree_nodelong long::_M_storage

2015-05-22 Thread Jonathan Wakely
There are two problems involved in this PR. First, as Clang's ubsan detects, we are using static_cast to convert from _Rb_tree_node_base* to _Rb_tree_node_Val* in cases where there is no _Rb_tree_node_Val at that address (_M_impl._M_header is just an _Rb_tree_node_base). That's undefined

Re: [patch] libstdc++/66017 Avoid bad casts and fix alignment of _Rb_tree_nodelong long::_M_storage

2015-05-22 Thread Jonathan Wakely
On 22/05/15 16:29 +0200, Jakub Jelinek wrote: On Fri, May 22, 2015 at 03:15:10PM +0100, Jonathan Wakely wrote: --- a/libstdc++-v3/include/ext/aligned_buffer.h +++ b/libstdc++-v3/include/ext/aligned_buffer.h @@ -31,21 +31,23 @@ #pragma GCC system_header -#if __cplusplus = 201103L -# include

Re: [patch] libstdc++/66017 Avoid bad casts and fix alignment of _Rb_tree_nodelong long::_M_storage

2015-05-22 Thread Jonathan Wakely
On 22/05/15 17:13 +0200, Jakub Jelinek wrote: On Fri, May 22, 2015 at 03:59:47PM +0100, Jonathan Wakely wrote: + alignas(alignof(_Tp2)) unsigned char _M_storage[sizeof(_Tp)]; Is alignof(_Tp2) always the same as alignof(_Tp2::_M_t) on all targets (I mean, won't some target align the

Re: [patch] libstdc++/66017 Avoid bad casts and fix alignment of _Rb_tree_nodelong long::_M_storage

2015-05-22 Thread Jakub Jelinek
On Fri, May 22, 2015 at 03:15:10PM +0100, Jonathan Wakely wrote: --- a/libstdc++-v3/include/ext/aligned_buffer.h +++ b/libstdc++-v3/include/ext/aligned_buffer.h @@ -31,21 +31,23 @@ #pragma GCC system_header -#if __cplusplus = 201103L -# include type_traits -#else +#if __cplusplus

Re: [patch] libstdc++/66017 Avoid bad casts and fix alignment of _Rb_tree_nodelong long::_M_storage

2015-05-22 Thread Jakub Jelinek
On Fri, May 22, 2015 at 03:59:47PM +0100, Jonathan Wakely wrote: + alignas(alignof(_Tp2)) unsigned char _M_storage[sizeof(_Tp)]; Is alignof(_Tp2) always the same as alignof(_Tp2::_M_t) on all targets (I mean, won't some target align the structure more than its only field)? Hmm, maybe.

Re: [patch] libstdc++/66017 Avoid bad casts and fix alignment of _Rb_tree_nodelong long::_M_storage

2015-05-22 Thread Martin Sebor
On 05/22/2015 09:13 AM, Jakub Jelinek wrote: On Fri, May 22, 2015 at 03:59:47PM +0100, Jonathan Wakely wrote: + alignas(alignof(_Tp2)) unsigned char _M_storage[sizeof(_Tp)]; Is alignof(_Tp2) always the same as alignof(_Tp2::_M_t) on all targets (I mean, won't some target align the

Re: [patch] libstdc++/66017 Avoid bad casts and fix alignment of _Rb_tree_nodelong long::_M_storage

2015-05-22 Thread Jonathan Wakely
On 22/05/15 16:21 +0100, Jonathan Wakely wrote: On 22/05/15 17:13 +0200, Jakub Jelinek wrote: On Fri, May 22, 2015 at 03:59:47PM +0100, Jonathan Wakely wrote: + alignas(alignof(_Tp2)) unsigned char _M_storage[sizeof(_Tp)]; Is alignof(_Tp2) always the same as alignof(_Tp2::_M_t) on all