[libcxx-commits] [libcxx] [libcxx] Enrich message for std::bad_variant_access exception (PR #196495)

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Thu Jun 18 10:17:43 PDT 2026


================
@@ -309,11 +322,11 @@ struct __farray {
   _LIBCPP_HIDE_FROM_ABI constexpr const _Tp& operator[](size_t __n) const noexcept { return __buf_[__n]; }
 };
 
-[[noreturn]] inline _LIBCPP_HIDE_FROM_ABI void __throw_bad_variant_access() {
+[[noreturn]] inline _LIBCPP_HIDE_FROM_ABI void __throw_bad_variant_access(const char* __msg) {
 #    if _LIBCPP_HAS_EXCEPTIONS
-  throw bad_variant_access();
+  throw __bad_variant_access_with_msg(__msg);
----------------
ldionne wrote:

Ville replied to the email. It seems the intent is that we're allowed to throw a derived type, and the Effects vs Throws difference is not intended. I'll also file a LWG issue about this but this means we can keep this patch in as-is.

https://github.com/llvm/llvm-project/pull/196495


More information about the libcxx-commits mailing list