The following code generates a dead-code block error when running with --enable=all.
Checked against commit 87e7b57170a82a601e7c8289c75acf26b46a40d9
[tmp.cpp:11] -> [tmp.cpp:13]: (warning) Opposite inner 'if' condition leads to a dead code block.
#include <iostream> #include <cstdlib> #include <vector> using namespace std; int main() { vector<int> v = {};//1,3,4}; if(v.size() !=1) { if(v.empty()) cerr << "V is empty" << endl; else cerr << "V is bigger than one" << endl; } }
This one still reproduces with v2.3.
Apparently, this has been fixed in the meantime. Head gives the correct warnings
53684d14a2.cpp:11:17: style: Condition 'v.size()!=1' is always true [knownConditionTrueFalse] if(v.size() !=1) ^ 53684d14a2.cpp:13:19: style: Condition 'v.empty()' is always true [knownConditionTrueFalse] if(v.empty()) ^
It also correctly handles the case v = {1,3,4};.
v = {1,3,4};
Log in to post a comment.
The following code generates a dead-code block error when running with --enable=all.
Checked against commit 87e7b57170a82a601e7c8289c75acf26b46a40d9
This one still reproduces with v2.3.
Apparently, this has been fixed in the meantime. Head gives the correct warnings
It also correctly handles the case
v = {1,3,4};
.