-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Closed
Labels
bugSomething isn't workingSomething isn't workingfixedSomething works now, yay!Something works now, yay!
Description
Describe the bug
During implementation #50 i found that string_view::copy mistakenly marked constexpr before p1032r1
Command-line test case
I guess all versions with string_view support:
C:\Users\billy\Desktop>type string_view_copy.cpp
#include <string_view>
#include <array>
constexpr auto test_string_view_copy() {
std::string_view a("oops");
std::array<char,3> a1 = {'1','2','3'};
a.copy(a1.data(), 3);
return a1.size();
}
int main() {
constexpr auto n = test_string_view_copy();
}
C:\Users\billy\Desktop>cl /EHsc /W4 /WX .\cl /std:c++17 /EHsc /MDd /W4 /WX string_view_copy.cpp
Microsoft (R) C/C++ Optimizing Compiler Version 19.23.28106.4 for x64
Copyright (C) Microsoft Corporation. All rights reserved.
string_view_copy.cpp
string_view_copy.cpp(13): error C2131: expression did not evaluate to a constant
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.23.28105\include\xstring(1322): note: failure was caused by call of undefined function or one not declared 'constexpr'
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.23.28105\include\xstring(1322): note: see usage of 'std::_Narrow_char_traits<char,int>::copy'
Expected behavior
Something like this
cl /std:c++17 /EHsc /MDd /W4 /WX string_view_copy.cpp
Microsoft (R) C/C++ Optimizing Compiler Version 19.23.28106.4 for x64
Copyright (C) Microsoft Corporation. All rights reserved.
string_view_copy.cpp
string_view_copy.cpp(4): error C3615: constexpr function 'test_string_view_copy' cannot result in a constant expression
string_view_copy.cpp(7): note: failure was caused by call of undefined function or one not declared 'constexpr'
string_view_copy.cpp(7): note: see usage of 'std::basic_string_view<char,std::char_traits<char>>::copy'
string_view_copy.cpp(13): error C2131: expression did not evaluate to a constant
string_view_copy.cpp(13): note: function violates 'constexpr' rules or has errors
string_view_copy.cpp(13): note: see usage of 'test_string_view_copy'
Additional context
Add any other context about the problem here.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingfixedSomething works now, yay!Something works now, yay!