-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Closed
Labels
bugSomething isn't workingSomething isn't workingcompilerCompiler work involvedCompiler work involvedfixedSomething works now, yay!Something works now, yay!
Description
Description
Comparison of std::string yields different results when performed at runtime vs. compile time:
- https://godbolt.org/z/7EzP86efo (
std::string::operator<()) - https://godbolt.org/z/MP4GMzbjf (
std::string::compare()) - https://godbolt.org/z/Ejzv3eTe6 (
std::string::traits_type::compare())
The underlying compiler issue with respect to __builtin_memcmp() was reported in July 2024.
One commenter suggested reporting the problem here in the hope of generating the necessary attention.
Command-line test case
C:\Temp>type repro.cpp
#include <cassert>
#include <string>
int main()
{
constexpr std::string a = "\x01";
constexpr std::string b = "\xFF";
auto r = (a < b);
assert(r);
constexpr auto c = (a < b);
static_assert(c);
}
C:\Temp>cl /nologo /std:c++20 repro.cpp
repro.cpp
repro.cpp(13): error C2607: static assertion failed
Expected behavior
Compilation should succeed without error as it was the case until v17.9:
C:\Temp>cl /std:c++20 repro.cpp
Microsoft (R) C/C++ Optimizing Compiler Version 19.39.33523 for x64
Copyright (C) Microsoft Corporation. All rights reserved.
repro.cpp
Microsoft (R) Incremental Linker Version 14.39.33523.0
Copyright (C) Microsoft Corporation. All rights reserved.
/out:repro.exe
repro.obj
STL version
Last working version:
Microsoft Visual Studio Professional 2022 (64-bit)
Version 17.9.7
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingcompilerCompiler work involvedCompiler work involvedfixedSomething works now, yay!Something works now, yay!