From 79e4cf33e88e2118b3d6158ab6d3c047a744646e Mon Sep 17 00:00:00 2001 From: Liu Zhangjian Date: Thu, 5 Dec 2024 20:08:53 +0800 Subject: [PATCH] fix: [gcctoolchain] Fix GCC compiler version detection issue Fixed incorrect position check for compiler version detection in `findCompilerCandidates` function. Changed from `pos + 2` to `pos + 1` to properly detect compiler names with single digit versions like gcc-8 and clang-7. Change-Id: I6eb16c6c88a8944ee67af42ea4c9fb244cbdb7e8 Reviewed-by: Christian Kandeler Reviewed-by: Orgad Shaneh --- src/plugins/projectexplorer/gcctoolchain.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/plugins/projectexplorer/gcctoolchain.cpp b/src/plugins/projectexplorer/gcctoolchain.cpp index 7dbae83b62f..6c35a127efb 100644 --- a/src/plugins/projectexplorer/gcctoolchain.cpp +++ b/src/plugins/projectexplorer/gcctoolchain.cpp @@ -1406,6 +1406,7 @@ static FilePaths findCompilerCandidates(OsType os, if (os == OsTypeWindows && fileName.endsWith(u".exe", Qt::CaseInsensitive)) fileName.chop(4); + // Do not `continue`, proceed to detect further variants if (fileName == compilerName) compilerPaths << executable; @@ -1426,7 +1427,7 @@ static FilePaths findCompilerCandidates(OsType os, // if not at the end, it must by followed by a hyphen and a digit between 1 and 9 pos += cl; if (pos != fileName.size()) { - if (pos + 2 >= fileName.size()) + if (pos + 1 >= fileName.size()) continue; if (fileName.at(pos) != '-') continue;