"constexpr std::string cs{ "hello" };" works in godbolt, but not in VS

39 views
Skip to first unread message

Heng Zhou

unread,
Oct 5, 2024, 6:15:53 AM10/5/24
to Compiler Explorer Discussion

The statement in question is:

constexpr std::string cs{ "hello" };

godbolt says it is OK since x64 msvc v19.34 VS 17.4. I installed Visual Studio 2022 version 17.11.4 with msvc 19.41.34120 for x86, but this statement still causes an error in VS: error C2131: expression did not evaluate to a constant. Do you how to have this constexpr statement compile in VS? Thanks.

Reply all
Reply to author
Forward
0 new messages