-
Notifications
You must be signed in to change notification settings - Fork 14.9k
Open
Labels
clang-tidyinvalid-code-generationTool (e.g. clang-format) produced invalid code that no longer compilesTool (e.g. clang-format) produced invalid code that no longer compiles
Description
Reproducer: https://godbolt.org/z/cKfnavMvb
#include <string>
#include <iostream>
struct Foo {
std::string appName;
int maxCopy;
};
int main()
{
std::string app;
Foo fileMeta;
int maxCopy;
bool x = !(app == fileMeta.appName && maxCopy == fileMeta.maxCopy);
}
clang-tidy shows:
<source>:13:10: warning: Value stored to 'x' during its initialization is never read [clang-analyzer-deadcode.DeadStores]
13 | bool x = !(app == fileMeta.appName && maxCopy == fileMeta.maxCopy);
| ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<source>:13:10: note: Value stored to 'x' during its initialization is never read
13 | bool x = !(app == fileMeta.appName && maxCopy == fileMeta.maxCopy);
| ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<source>:13:14: warning: boolean expression can be simplified by DeMorgan's theorem [readability-simplify-boolean-expr]
13 | bool x = !(app == fileMeta.appName && maxCopy == fileMeta.maxCopy);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| ! || !=
2 warnings generated.
But it should be app != fileMeta.appName || maxCopy != fileMeta.maxCopy)
Metadata
Metadata
Assignees
Labels
clang-tidyinvalid-code-generationTool (e.g. clang-format) produced invalid code that no longer compilesTool (e.g. clang-format) produced invalid code that no longer compiles