[libcxx-commits] [libcxx] [libc++][vector] Make constructor vector(count, value, allocator) exception-safe (PR #82033)

Nikolas Klauser via libcxx-commits libcxx-commits at lists.llvm.org
Fri Feb 16 16:17:49 PST 2024


philnik777 wrote:

As the comment in the test says, it's there to make sure that throwing in the constructors doesn't leak memory. It was never meant to check that all the correct destructors were run. If you want to take up the effort to improve the test coverage of exceptions in the `vector` constructors (and maybe other containers?) that would be great. I 100% agree that we need a lot better coverage in that area. AFAIK before #80558 we didn't have any coverage for destructing all the elements properly.

Regarding what exactly to do, I think it would be good to first fix `exceptions.pass.cpp` by adding `assert(false)` to make sure there are actually exceptions that are caught and fix any problems. Maybe also rename it to something that makes it clear the tests are only about memory leaks. After that I'd add a new test to make sure all the elements are destroyed correctly.

You can use any extensions that Clang provides in C++03. `initializer_list`s aren't provided as an extension in C++11, so the tests have to be guarded behind `TEST_STD_VER >= 11`.


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


More information about the libcxx-commits mailing list