-
Notifications
You must be signed in to change notification settings - Fork 15.2k
Open
Labels
clang:diagnosticsNew/improved warning or error message in Clang, but not in clang-tidy or static analyzerNew/improved warning or error message in Clang, but not in clang-tidy or static analyzer
Description
The conditional-uninitialized diagnostics checker issue warnings even in cases when the initialization is clearly performed.
Here is the example:
int a(int p1)
{
int cv = 1;
int ibn;
if ((cv < 5) && (p1 == 1))
{
ibn = 2;
p1 += 1;
cv++;
}
if(cv == 2)
{
return ibn;
}
return 8;
}
The warning generated is: "warning: variable 'ibn' may be uninitialized when used here [-Wconditional-uninitialized]".
In this case depending on the passed value p1 the variable ibn might be not initialized when used in the return statement.
However the code is written in such way that variable return ibn; line is executed only when ibn = 2; is also executed. Thus the warning is technically superfluous.
The godbolt example to play with: https://godbolt.org/z/qnhq9YE61.
Metadata
Metadata
Assignees
Labels
clang:diagnosticsNew/improved warning or error message in Clang, but not in clang-tidy or static analyzerNew/improved warning or error message in Clang, but not in clang-tidy or static analyzer