-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[P0980R1] constexpr std::string #1502
Conversation
18e41c0
to
b6d5ba5
Compare
Note that there is also a plethora of tests for other functionality missing like |
Urgh, I think I broke something ... |
768e6b6
to
5ae5719
Compare
urgh, @zygoloid i am sorry, that is going to be a hell of a bug report :(
|
Fun :)
Would it be feasible to give this a try with Clang trunk or the 11.0 release? I'm confident there are things we've fixed in the area of constexpr allocation since 10.0. |
I will try, once I find out which configuration is crashing. That said, the last time I tried to pull in llvm-project as a submodule my trusty workstation surrendered |
Unfortunately, it looks like the ICE in the filesystem libcxx tests persists even with Clang 11 😿
|
With the new changes clang flags the following code in deat_test.hpp ( STL/tests/std/include/test_death.hpp Lines 76 to 86 in 19c683d
const DWORD result_size = ::GetModuleFileNameW(nullptr, &result[0], static_cast<DWORD>(result.size()));
const size_t str_size = result.size();
if (result_size == str_size) {
// buffer was not big enough
const size_t str_max_size = result.max_size();
const size_t result_max_size = str_max_size - str_max_size / 2;
if (result_size >= result_max_size) {
api_unexpected("GetModuleFileNameW");
}
result.resize(result_size + result_size / 2); Importantly, _NODISCARD static constexpr size_type max_size(const _Alloc&) noexcept {
return static_cast<size_t>(-1) / sizeof(value_type);
} With |
8212b6a
to
166c258
Compare
71975e3
to
92e8341
Compare
435935e
to
ce41ce1
Compare
@zygoloid we had a host of crashes with this PR (See https://github.com/microsoft/STL/runs/1486997695) I found that with clang-10 the bug was with the default constructor of the However, it seems that we still get the ICE from @mnatsuhara was investigating this on clang-11 and the crash is not solved with clang 11. She also experienced other failures that were not remedied with the smal workaround |
I switched back to Clang 10 to verify that the issue of the The |
I don't have an environment set up to build using the MS STL, but if folks here can provide me with preprocessed sources that trigger a crash, I can take a look. |
I've pushed a perma-workaround for Microsoft-internal VSO-1285539 "REPORTED: EDG ICE with STL/tests/std/tests/VSO_0102478_moving_allocators/test.cpp Lines 67 to 90 in 663f0dd
These function- static vector s containing string s were causing trouble for EDG now, and MSVC earlier (with the bugs that @mnatsuhara reported, fixed in 16.10 Preview 1). We can perma-workaround all of this, removing all guards for __EDG__ and MSVC_INTERNAL_TESTING , plus the pre-existing warning C4640: construction of local static object is not thread-safe suppression, by using constexpr array s containing const char* . (string_view isn't available in C++14 mode.)
We need to adjust |
Changes requested in Dec 2020 have been made
static_assert("Thanks for implementing this major C++20 feature!"s
== "Thanks for implementing "s + "this major C++20 feature!"s); Amazing work, @miscco and @mnatsuhara! This will ship in VS 2019 16.10 Preview 2! 🚀 😺 🥇 |
I could not resist.
This implements constexpr string for clang only. Currently we are still blocked for MSVC due to the bug with the constexpr destructor.
There are some notable wrinkles:
Capacity: I have no Idea how this works
There is some subtle bug regarding the move + allocator constructor and some other constructors (those that are currently commented out), where we seem to have a double delete.
There is undefined behavior in string.insert(). We are checking for self inserts, where comparisons of pointers of different arrays are done. Here we need a fix similar to what we did in char_traits::copy where we linearly walk the buffer.
Testing is hell. I am through with
char
but need to find a clean way to testwchar_t
Fixes #43.