[libcxx-commits] [libcxx] [libcxx] Initialize vcruntime __std_exception_data in the exception copy ctor (PR #144329)
Martin Storsjö via libcxx-commits
libcxx-commits at lists.llvm.org
Mon Jun 16 03:50:40 PDT 2025
https://github.com/mstorsjo created https://github.com/llvm/llvm-project/pull/144329
This fixes failures in a number of tests, in the
clang-cl-no-vcruntime configuration (where libcxx provides dummy, no-op replacements of some vcruntime base exception classes), if building with optimization enabled.
Previously, with optimization enabled, the compiler concluded that these fields would be uninitialized at the points of asserts in the tests.
This fixes the following tests in this configuration:
llvm-libc++-shared-no-vcruntime-clangcl.cfg.in :: std/language.support/support.dynamic/alloc.errors/bad.alloc/bad_alloc.pass.cpp
llvm-libc++-shared-no-vcruntime-clangcl.cfg.in :: std/language.support/support.dynamic/alloc.errors/new.badlength/bad_array_new_length.pass.cpp
llvm-libc++-shared-no-vcruntime-clangcl.cfg.in :: std/language.support/support.exception/bad.exception/bad_exception.pass.cpp
llvm-libc++-shared-no-vcruntime-clangcl.cfg.in :: std/language.support/support.exception/exception/exception.pass.cpp
llvm-libc++-shared-no-vcruntime-clangcl.cfg.in :: std/language.support/support.rtti/bad.cast/bad_cast.pass.cpp
llvm-libc++-shared-no-vcruntime-clangcl.cfg.in :: std/language.support/support.rtti/bad.typeid/bad_typeid.pass.cpp
>From 10913dfada303c2709d59b71fccd91b7a539a49c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Martin=20Storsj=C3=B6?= <martin at martin.st>
Date: Sun, 15 Jun 2025 01:07:41 +0300
Subject: [PATCH] [libcxx] Initialize vcruntime __std_exception_data in the
exception copy ctor
This fixes failures in a number of tests, in the
clang-cl-no-vcruntime configuration (where libcxx provides dummy,
no-op replacements of some vcruntime base exception classes), if
building with optimization enabled.
Previously, with optimization enabled, the compiler concluded that
these fields would be uninitialized at the points of asserts in
the tests.
This fixes the following tests in this configuration:
llvm-libc++-shared-no-vcruntime-clangcl.cfg.in :: std/language.support/support.dynamic/alloc.errors/bad.alloc/bad_alloc.pass.cpp
llvm-libc++-shared-no-vcruntime-clangcl.cfg.in :: std/language.support/support.dynamic/alloc.errors/new.badlength/bad_array_new_length.pass.cpp
llvm-libc++-shared-no-vcruntime-clangcl.cfg.in :: std/language.support/support.exception/bad.exception/bad_exception.pass.cpp
llvm-libc++-shared-no-vcruntime-clangcl.cfg.in :: std/language.support/support.exception/exception/exception.pass.cpp
llvm-libc++-shared-no-vcruntime-clangcl.cfg.in :: std/language.support/support.rtti/bad.cast/bad_cast.pass.cpp
llvm-libc++-shared-no-vcruntime-clangcl.cfg.in :: std/language.support/support.rtti/bad.typeid/bad_typeid.pass.cpp
---
libcxx/include/__exception/exception.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libcxx/include/__exception/exception.h b/libcxx/include/__exception/exception.h
index f7dab6e83ad14..161cc49979e4a 100644
--- a/libcxx/include/__exception/exception.h
+++ b/libcxx/include/__exception/exception.h
@@ -48,7 +48,7 @@ class exception { // base of all library exceptions
__data_._DoFree = true;
}
- exception(exception const&) _NOEXCEPT {}
+ exception(exception const&) _NOEXCEPT : __data_() {}
exception& operator=(exception const&) _NOEXCEPT { return *this; }
More information about the libcxx-commits
mailing list