[PATCH] D12299: [libcxx] ABI-Breaking Fix for ALL undefined behavior in <list>.

Andreas Jacobs via cfe-commits cfe-commits at lists.llvm.org
Tue Aug 25 11:40:48 PDT 2015


awi added a subscriber: awi.
awi added a comment.

Hello,
I like your patch very much. I looks similar to my patch from January, so I am confident it solves my problem, but it does so a little more elegantly at some places.
I tried it with my two sources files main.cpp and main2.cpp. While main.cpp works with or without your patch, main2.cpp fails with the current svn head, but succeeds with your patch.
After that I executed the libc++ test suite, using `-std=c++1y` as the language version. Here, a couple of tests failed to compile. This is not as bad as it may sound, though, because I could fix it by adding some missing calls to your new `__list_node_base` functions `__as_base()` and `__as_node()`:

  --- include/list	2015-08-25 20:35:00.769897378 +0200
  +++ include/list.corr	2015-08-25 20:10:38.000000000 +0200
  @@ -1362,9 +1362,9 @@
           __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), __x);
           ++__ds;
   #if _LIBCPP_DEBUG_LEVEL >= 2
  -        __r = iterator(__hold.get(), this);
  +        __r = iterator(__hold.get()->__as_base(), this);
   #else
  -        __r = iterator(__hold.get());
  +        __r = iterator(__hold.get()->__as_base());
   #endif
           __hold.release();
           iterator __e = __r;
  @@ -1376,7 +1376,7 @@
               {
                   __hold.reset(__node_alloc_traits::allocate(__na, 1));
                   __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), __x);
  -                __e.__ptr_->__next_ = __hold.get();
  +                __e.__ptr_->__next_ = __hold.get()->__as_base();
                   __hold->__prev_ = __e.__ptr_;
                   __hold.release();
               }
  @@ -1388,7 +1388,7 @@
               {
                   __node_alloc_traits::destroy(__na, _VSTD::addressof(*__e));
                   __node_base_pointer __prev = __e.__ptr_->__prev_;
  -                __node_alloc_traits::deallocate(__na, __e.__ptr_, 1);
  +                __node_alloc_traits::deallocate(__na, __e.__ptr_->__as_node(), 1);
                   if (__prev == 0)
                       break;
   #if _LIBCPP_DEBUG_LEVEL >= 2


http://reviews.llvm.org/D12299





More information about the cfe-commits mailing list