================
@@ -82,9 +82,11 @@ class LibclangParseTest : public ::testing::Test {
fixed_addr_string(new std::string(Filename)),
fixed_addr_string(new std::string(Contents))));
UnsavedFiles.push_back({
- it.first->first->c_str(), // filename
- it.first->second->c_str(), // contents
- it.first->second->size() // length
+ it.first->first->c_str(), // filename
+ it.first->second->c_str(), // contents
+ // CXUnsavedFile::Length is `unsigned long`, which is 32 bits on
+ // 64-bit Windows, so converting from size_t here narrows.
+ static_cast<unsigned long>(it.first->second->size()) // length
----------------
UebelAndre wrote:
I ran the test again and was wrong about this being a warning, it's actually a
hard error. The fixture does `UnsavedFiles.push_back({name, contents,
str.size()})`, which is copy-list-initialization, so narrowing from
`std::string::size_type` (64-bit) to `unsigned long` (32-bit on Win64) is
ill-formed. MSVC 19.51 reports `error C2397` in every mode, independent of /WX.
clang-cl reports it under -Wc++11-narrowing, which is a default error. This is
not hit in CI because the tests are excluded in CMake on windows:
https://github.com/llvm/llvm-project/blob/a2e260fdb96317e1ca1c994f898851b733d97f4d/clang/unittests/CMakeLists.txt#L100-L104
I hit this by running tests with Bazel which at least define the buildable
targets there.
https://github.com/llvm/llvm-project/pull/228405
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits