Skip to content

Commit 38ed8fb

Browse files
authored
[tools/val] Paper over type change for std::filesystem::path::u8string (KhronosGroup#6336)
In C++17 the type is std::string, in C++20 it's std::u8string. Then the .c_str() for both have incompatible types. Paper over this difference by copying to a std::string before invoking the helper function
1 parent 1a2d8dd commit 38ed8fb

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

tools/val/val.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,13 @@ int main(int argc, char** argv) {
266266

267267
if (filepath.extension() != ".spv") continue;
268268

269+
// Copy the string, because in C++20 the result type of
270+
// std::filesystem::path::u8string changes type from std::string to
271+
// std::u8string, and the pointer type ends up incompatible. Normalize
272+
// to std::string first via copying.
273+
const auto filepath_u8str = filepath.u8string();
274+
const std::string filepath_str(filepath_u8str.begin(),
275+
filepath_u8str.end());
269276
if (!process_single_file(filepath.u8string().c_str(), target_env, options,
270277
false)) {
271278
succeed = false;

0 commit comments

Comments
 (0)