[libcxx-commits] [PATCH] D96946: [libcxx][RFC] Unspecified behavior randomization in libcxx

Danila Kutenin via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Tue Nov 16 07:24:59 PST 2021


danlark added inline comments.


================
Comment at: libcxx/include/__algorithm/shuffle.h:28
 
+#if defined(_LIBCPP_DEBUG_RANDOMIZE_UNSPECIFIED_STABILITY) || defined(_LIBCPP_BUILDING_LIBRARY)
+
----------------
Question, windows DLLs were not able to build the tests without _LIBCPP_BUILDING_LIBRARY as I guess because of constructor/destructor ABI of trivial types, should I leave it like that?

Linux and MacOS seem fine without it


================
Comment at: libcxx/include/__config:867-874
+#if defined(_LIBCPP_DEBUG_RANDOMIZE_UNSPECIFIED_STABILITY)
+#  if defined(_LIBCPP_CXX03_LANG)
+#    error Support for unspecified stability is only for C++11 and higher
+#  endif
+#  define _LIBCPP_DEBUG_RANDOMIZE_RANGE(__first, __last) do { if (!__builtin_is_constant_evaluated()) _VSTD::shuffle(__first, __last, __libcpp_debug_randomizer()); } while (0)
+#else
+#  define _LIBCPP_DEBUG_RANDOMIZE_RANGE(__first, __last) (void)0
----------------
ldionne wrote:
> Personally I preferred the previous version where you had these checks inlined in the algorithms. I should have said it, sorry for the churn. Anyway, feel free to do it however you prefer.
I actually prefer the macro, the change looks cleaner


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D96946/new/

https://reviews.llvm.org/D96946



More information about the libcxx-commits mailing list