[vcpkg] Avoid modifying static globals after initialization
MODIFY
src/PostBuildLint.cpp
src/PostBuildLint.cpp
@@ -48,7 +48,8 @@ namespace vcpkg::PostBuildLint
const std::vector<OutdatedDynamicCrt>& get_outdated_dynamic_crts(const std::map<BuildPolicies, bool>& policies)
{
- static std::vector<OutdatedDynamicCrt> v = {{"msvcp100.dll", R"(msvcp100\.dll)"},
+ static const std::vector<OutdatedDynamicCrt> v_no_msvcrt = {
+ {"msvcp100.dll", R"(msvcp100\.dll)"},
{"msvcp100d.dll", R"(msvcp100d\.dll)"},
{"msvcp110.dll", R"(msvcp110\.dll)"},
{"msvcp110_win.dll", R"(msvcp110_win\.dll)"},
@@ -66,9 +67,15 @@ namespace vcpkg::PostBuildLint
{"msvcrt20.dll", R"(msvcrt20\.dll)"},
{"msvcrt40.dll", R"(msvcrt40\.dll)"}};
+ static const std::vector<OutdatedDynamicCrt> v = [&]() {
+ auto ret = v_no_msvcrt;
+ ret.push_back(OutdatedDynamicCrt{"msvcrt.dll", R"(msvcrt\.dll)"});
+ return ret;
+ }();
+
if (contains_and_enabled(policies, BuildPoliciesC::ALLOW_OBSOLETE_MSVCRT))
{
- v.push_back(OutdatedDynamicCrt{"msvcrt.dll", R"(msvcrt\.dll)"});
+ return v_no_msvcrt;
}
return v;

[vcpkg] Avoid modifying static globals after initialization