Skip to content

Commit 4765d19

Browse files
committed
fix(msvc): const ref when iterating path segments — libc++ yields temporaries
GCC/libstdc++ and Clang/MSVC-STL accepted 'auto&' here; Clang/libc++ (macOS job) correctly rejects binding a non-const lvalue ref to the temporary.
1 parent d0bf7bb commit 4765d19

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

src/toolchain/msvc.cppm

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,8 @@ namespace {
290290
// "…\Microsoft Visual Studio\2022\BuildTools" → "2022 BuildTools".
291291
[[maybe_unused]] std::string product_from_vs_root(const std::filesystem::path& vsRoot) {
292292
std::vector<std::string> parts;
293-
for (auto& seg : vsRoot) parts.push_back(seg.string());
293+
// path iterators yield temporaries under libc++ — const ref only.
294+
for (const auto& seg : vsRoot) parts.push_back(seg.string());
294295
for (std::size_t i = 0; i + 2 < parts.size(); ++i) {
295296
if (parts[i] == "Microsoft Visual Studio")
296297
return parts[i + 1] + " " + parts[i + 2];

0 commit comments

Comments
 (0)