Skip to content

Fix false duplicate warnings with string prefix macros - #8834

Open
tzi4 wants to merge 1 commit into
cppcheck-opensource:mainfrom
tzi4:fix/trac-5738-string-prefix
Open

Fix false duplicate warnings with string prefix macros#8834
tzi4 wants to merge 1 commit into
cppcheck-opensource:mainfrom
tzi4:fix/trac-5738-string-prefix

Conversation

@tzi4

@tzi4 tzi4 commented Sep 7, 2026

Copy link
Copy Markdown

This fixes the false duplicateExpression warning reported in Trac #5738.

I reproduced it with expressions like this:

name == SRCDIR "/a" || name == SRCDIR "/b"

The startswith(...) case from this ticket was fixed in July 2018. The direct comparisons above still trigger the warning on current main. This PR addresses those remaining comparisons.

When SRCDIR is undefined, Cppcheck compares the macro names and misses the different strings after them. The patch prevents that incomplete comparison from producing a duplicate warning.

I added regression tests for the reported case and checked that real duplicates still produce warnings, including identical throw expressions. The three focused tests fail before the fix and pass after it. The full C++ suite passes with 5,323 tests and 355 existing TODOs. These checks ran on Linux/WSL at commit c976cac0ec531e1ff47b8cf78028f1182e84a35e.

I found this issue through the bounty page. Is the program still running, and would this fix qualify for the listed $20? I'm based in Türkiye and can also receive crypto. Which payment methods do you support, and roughly how long does payment usually take?

I also have local fixes for Trac #6552 and Trac #4270. How should I request assignment for those?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant