From a200811694e4f2ff6d1487997f2d2048443b627b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludvig=20Gunne=20Lindstr=C3=B6m?= Date: Thu, 4 Sep 2025 14:28:24 +0200 Subject: [PATCH 1/2] add test --- test/teststring.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/test/teststring.cpp b/test/teststring.cpp index 3d07b4774a9..02bf749bf04 100644 --- a/test/teststring.cpp +++ b/test/teststring.cpp @@ -823,6 +823,13 @@ class TestString : public TestFixture { " if (strequ(p, \"ALL\")) {}\n" "}\n"); ASSERT_EQUALS("", errout_str()); + + check("void f(std::string_view);\n" + "void f(bool);\n" + "void g() {\n" + " f(\"\"sv);\n" + "}\n"); + ASSERT_EQUALS("", errout_str()); } void deadStrcmp() { From 786589874530cd1d24a1ef01992b8b17bf264868 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludvig=20Gunne=20Lindstr=C3=B6m?= Date: Thu, 4 Sep 2025 14:24:43 +0200 Subject: [PATCH 2/2] fix #14058 --- lib/checkstring.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/checkstring.cpp b/lib/checkstring.cpp index c6d4cb88cab..64b575df72d 100644 --- a/lib/checkstring.cpp +++ b/lib/checkstring.cpp @@ -318,6 +318,7 @@ void CheckString::checkIncorrectStringCompare() } } } else if (Token::Match(tok, "%str%|%char%") && + !Token::Match(tok->next(), "%name%") && isUsedAsBool(tok, *mSettings) && !isMacroUsage(tok)) incorrectStringBooleanError(tok, tok->str());