[libcxx-commits] [libcxx] [libcxx] Enrich message for std::bad_variant_access exception (PR #196495)
Nikita Grivin via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Jun 18 10:58:03 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);
----------------
MindSpectre wrote:
Since the standard text turned out to be ambiguous enough to need clarification, user code may have been written assuming `typeid(exc) == typeid(std::bad_variant_access)` is okay. The current release note covers the what() string change but not the typeid behavior change.
Is there a libc++ convention for surfacing this kind of subtle behavioral shift to users - extending the release note, an entry somewhere else, or is it considered sufficient that the LWG resolution itself constitutes notice?
https://github.com/llvm/llvm-project/pull/196495
More information about the libcxx-commits
mailing list