You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
errmsg = "Out of bounds access in expression '" + expression + "' because '$symbol' is empty and '" + index + "' may be non-zero.";
242
242
else
243
243
errmsg = "Out of bounds access in expression '" + expression + "' because '$symbol' is empty.";
244
244
} elseif (indexValue) {
245
245
if (containerSize->condition)
246
-
errmsg = ValueFlow::eitherTheConditionIsRedundant(containerSize->condition) + " or $symbol size can be " + std::to_string(containerSize->intvalue) + ". Expression '" + expression + "' cause access out of bounds.";
246
+
errmsg = ValueFlow::eitherTheConditionIsRedundant(containerSize->condition) + " or size of '$symbol' can be " + std::to_string(containerSize->intvalue) + ". Expression '" + expression + "' causes access out of bounds.";
247
247
elseif (indexValue->condition)
248
-
errmsg = ValueFlow::eitherTheConditionIsRedundant(indexValue->condition) + " or '" + index + "' can have the value " + indexValueString(*indexValue) + ". Expression '" + expression + "' cause access out of bounds.";
248
+
errmsg = ValueFlow::eitherTheConditionIsRedundant(indexValue->condition) + " or '" + index + "' can have the value " + indexValueString(*indexValue) + ". Expression '" + expression + "' causes access out of bounds.";
249
249
else
250
250
errmsg = "Out of bounds access in '" + expression + "', if '$symbol' size is " + std::to_string(containerSize->intvalue) + " and '" + index + "' is " + indexValueString(*indexValue);
Copy file name to clipboardExpand all lines: test/teststl.cpp
+19-19Lines changed: 19 additions & 19 deletions
Original file line number
Diff line number
Diff line change
@@ -224,10 +224,10 @@ class TestStl : public TestFixture {
224
224
" bar(v[2], v[3]) )\n"// v[3] is accessed
225
225
" {;}\n"
226
226
"}\n");
227
-
ASSERT_EQUALS("test.cpp:9:warning:Either the condition 'v.size()>=2' is redundant or v size can be 2. Expression 'v[2]' cause access out of bounds.\n"
227
+
ASSERT_EQUALS("test.cpp:9:warning:Either the condition 'v.size()>=2' is redundant or size of 'v' can be 2. Expression 'v[2]' causes access out of bounds.\n"
228
228
"test.cpp:8:note:condition 'v.size()>=2'\n"
229
229
"test.cpp:9:note:Access out of bounds\n"
230
-
"test.cpp:9:warning:Either the condition 'v.size()>=2' is redundant or v size can be 2. Expression 'v[3]' cause access out of bounds.\n"
230
+
"test.cpp:9:warning:Either the condition 'v.size()>=2' is redundant or size of 'v' can be 2. Expression 'v[3]' causes access out of bounds.\n"
231
231
"test.cpp:8:note:condition 'v.size()>=2'\n"
232
232
"test.cpp:9:note:Access out of bounds\n", errout.str());
233
233
@@ -247,15 +247,15 @@ class TestStl : public TestFixture {
247
247
" v.front();\n"
248
248
" if (v.empty()) {}\n"
249
249
"}");
250
-
ASSERT_EQUALS("test.cpp:2:warning:Either the condition 'v.empty()' is redundant or expression 'v.front()' cause access out of bounds.\n"
250
+
ASSERT_EQUALS("test.cpp:2:warning:Either the condition 'v.empty()' is redundant or expression 'v.front()' causes access out of bounds.\n"
251
251
"test.cpp:3:note:condition 'v.empty()'\n"
252
252
"test.cpp:2:note:Access out of bounds\n", errout.str());
253
253
254
254
checkNormal("void f(std::vector<int> v) {\n"
255
255
" if (v.size() == 3) {}\n"
256
256
" v[16] = 0;\n"
257
257
"}");
258
-
ASSERT_EQUALS("test.cpp:3:warning:Either the condition 'v.size()==3' is redundant or v size can be 3. Expression 'v[16]' cause access out of bounds.\n"
258
+
ASSERT_EQUALS("test.cpp:3:warning:Either the condition 'v.size()==3' is redundant or size of 'v' can be 3. Expression 'v[16]' causes access out of bounds.\n"
259
259
"test.cpp:2:note:condition 'v.size()==3'\n"
260
260
"test.cpp:3:note:Access out of bounds\n", errout.str());
261
261
@@ -265,7 +265,7 @@ class TestStl : public TestFixture {
265
265
" v[i] = 0;\n"
266
266
" }\n"
267
267
"}");
268
-
ASSERT_EQUALS("test.cpp:4:warning:Either the condition 'v.size()==3' is redundant or v size can be 3. Expression 'v[i]' cause access out of bounds.\n"
268
+
ASSERT_EQUALS("test.cpp:4:warning:Either the condition 'v.size()==3' is redundant or size of 'v' can be 3. Expression 'v[i]' causes access out of bounds.\n"
269
269
"test.cpp:3:note:condition 'v.size()==3'\n"
270
270
"test.cpp:4:note:Access out of bounds\n", errout.str());
271
271
@@ -285,7 +285,7 @@ class TestStl : public TestFixture {
285
285
" s[2] = 0;\n"
286
286
" }\n"
287
287
"}");
288
-
ASSERT_EQUALS("test.cpp:3:warning:Either the condition 's.size()==1' is redundant or s size can be 1. Expression 's[2]' cause access out of bounds.\n"
288
+
ASSERT_EQUALS("test.cpp:3:warning:Either the condition 's.size()==1' is redundant or size of 's' can be 1. Expression 's[2]' causes access out of bounds.\n"
289
289
"test.cpp:2:note:condition 's.size()==1'\n"
290
290
"test.cpp:3:note:Access out of bounds\n", errout.str());
291
291
@@ -385,7 +385,7 @@ class TestStl : public TestFixture {
385
385
" if(v.at(b?42:0)) {}\n"
386
386
"}\n");
387
387
ASSERT_EQUALS(
388
-
"test.cpp:3:warning:Either the condition 'v.size()==1' is redundant or v size can be 1. Expression 'v.at(b?42:0)' cause access out of bounds.\n"
388
+
"test.cpp:3:warning:Either the condition 'v.size()==1' is redundant or size of 'v' can be 1. Expression 'v.at(b?42:0)' causes access out of bounds.\n"
389
389
"test.cpp:2:note:condition 'v.size()==1'\n"
390
390
"test.cpp:3:note:Access out of bounds\n",
391
391
errout.str());
@@ -628,7 +628,7 @@ class TestStl : public TestFixture {
ASSERT_EQUALS("test.cpp:2:warning:Either the condition 'v.size()>=1' is redundant or v size can be 1. Expression 'v[1]' cause access out of bounds.\n"
631
+
ASSERT_EQUALS("test.cpp:2:warning:Either the condition 'v.size()>=1' is redundant or size of 'v' can be 1. Expression 'v[1]' causes access out of bounds.\n"
632
632
"test.cpp:2:note:condition 'v.size()>=1'\n"
633
633
"test.cpp:2:note:Access out of bounds\n", errout.str());
634
634
@@ -641,7 +641,7 @@ class TestStl : public TestFixture {
641
641
" return y;\n"
642
642
"}\n");
643
643
ASSERT_EQUALS(
644
-
"test.cpp:6:warning:Either the condition 'x<2' is redundant or 'x' can have the value greater or equal to 3. Expression 'a[x]' cause access out of bounds.\n"
644
+
"test.cpp:6:warning:Either the condition 'x<2' is redundant or 'x' can have the value greater or equal to 3. Expression 'a[x]' causes access out of bounds.\n"
645
645
"test.cpp:3:note:condition 'x<2'\n"
646
646
"test.cpp:6:note:Access out of bounds\n",
647
647
errout.str());
@@ -692,10 +692,10 @@ class TestStl : public TestFixture {
692
692
" if (v[i]) {}\n"
693
693
" }\n"
694
694
"}\n");
695
-
ASSERT_EQUALS("test.cpp:3:warning:Either the condition 'i<=(int)v.size()' is redundant or 'i' can have the value v.size(). Expression 'v[i]' cause access out of bounds.\n"
695
+
ASSERT_EQUALS("test.cpp:3:warning:Either the condition 'i<=(int)v.size()' is redundant or 'i' can have the value v.size(). Expression 'v[i]' causes access out of bounds.\n"
696
696
"test.cpp:2:note:condition 'i<=(int)v.size()'\n"
697
697
"test.cpp:3:note:Access out of bounds\n"
698
-
"test.cpp:6:warning:Either the condition 'i<=static_cast<int>(v.size())' is redundant or 'i' can have the value v.size(). Expression 'v[i]' cause access out of bounds.\n"
698
+
"test.cpp:6:warning:Either the condition 'i<=static_cast<int>(v.size())' is redundant or 'i' can have the value v.size(). Expression 'v[i]' causes access out of bounds.\n"
@@ -730,7 +730,7 @@ class TestStl : public TestFixture {
730
730
"}\n",
731
731
true);
732
732
ASSERT_EQUALS(
733
-
"test.cpp:2:warning:Either the condition 'v.empty()' is redundant or expression 'v.back()' cause access out of bounds.\n"
733
+
"test.cpp:2:warning:Either the condition 'v.empty()' is redundant or expression 'v.back()' causes access out of bounds.\n"
734
734
"test.cpp:2:note:condition 'v.empty()'\n"
735
735
"test.cpp:2:note:Access out of bounds\n",
736
736
errout.str());
@@ -936,7 +936,7 @@ class TestStl : public TestFixture {
936
936
" int x = textline[col];\n"
937
937
"}\n");
938
938
ASSERT_EQUALS(
939
-
"[test.cpp:2] -> [test.cpp:4]: (warning) Either the condition 'col>textline.size()' is redundant or 'col' can have the value textline.size(). Expression 'textline[col]' cause access out of bounds.\n",
939
+
"[test.cpp:2] -> [test.cpp:4]: (warning) Either the condition 'col>textline.size()' is redundant or 'col' can have the value textline.size(). Expression 'textline[col]' causes access out of bounds.\n",
940
940
errout.str());
941
941
}
942
942
@@ -1108,7 +1108,7 @@ class TestStl : public TestFixture {
1108
1108
" l2.insert(it, 0);\n"
1109
1109
"}");
1110
1110
ASSERT_EQUALS("[test.cpp:6]: (error) Same iterator is used with different containers 'l1' and 'l2'.\n"
1111
-
"[test.cpp:6]: (error) Iterator 'it' from different container 'l2' are used together.\n",
1111
+
"[test.cpp:6]: (error) Iterator 'it' referring to container 'l1' is used with container 'l2'.\n",
1112
1112
errout.str());
1113
1113
1114
1114
check("void foo() {\n"// #5803
@@ -1857,7 +1857,7 @@ class TestStl : public TestFixture {
1857
1857
" while (it != g().end())\n"
1858
1858
" it = v.erase(it);\n"
1859
1859
"}\n");
1860
-
ASSERT_EQUALS("[test.cpp:6]: (error) Iterator 'it' from different container 'v' are used together.\n", errout.str());
1860
+
ASSERT_EQUALS("[test.cpp:6]: (error) Iterator 'it' referring to container 'g()' is used with container 'v'.\n", errout.str());
1861
1861
1862
1862
check("std::vector<int>& g(int);\n"
1863
1863
"void f(int i, int j) {\n"
@@ -1866,7 +1866,7 @@ class TestStl : public TestFixture {
1866
1866
" while (it != g(j).end())\n"
1867
1867
" it = r.erase(it);\n"
1868
1868
"}\n");
1869
-
ASSERT_EQUALS("[test.cpp:6]: (error) Iterator 'it' from different container 'r' are used together.\n", errout.str());
1869
+
ASSERT_EQUALS("[test.cpp:6]: (error) Iterator 'it' referring to container 'g(j)' is used with container 'r'.\n", errout.str());
1870
1870
1871
1871
check("std::vector<int>& g();\n"
1872
1872
"void f() {\n"
@@ -2085,13 +2085,13 @@ class TestStl : public TestFixture {
2085
2085
" a.insert(b.end(), value);\n"
2086
2086
" return a;\n"
2087
2087
"}");
2088
-
ASSERT_EQUALS("[test.cpp:3]: (error) Iterator 'b.end()' from different container 'a' are used together.\n", errout.str());
2088
+
ASSERT_EQUALS("[test.cpp:3]: (error) Iterator 'b.end()' referring to container 'b' is used with container 'a'.\n", errout.str());
2089
2089
2090
2090
check("std::vector<int> f(std::vector<int> a, std::vector<int> b) {\n"
2091
2091
" a.erase(b.begin());\n"
2092
2092
" return a;\n"
2093
2093
"}");
2094
-
ASSERT_EQUALS("[test.cpp:2]: (error) Iterator 'b.begin()' from different container 'a' are used together.\n", errout.str());
2094
+
ASSERT_EQUALS("[test.cpp:2]: (error) Iterator 'b.begin()' referring to container 'b' is used with container 'a'.\n", errout.str());
2095
2095
2096
2096
// #9973
2097
2097
check("void f() {\n"
@@ -3206,7 +3206,7 @@ class TestStl : public TestFixture {
3206
3206
" if (v.empty()) {}\n"
3207
3207
" v.pop_back();\n"
3208
3208
"}\n");
3209
-
ASSERT_EQUALS("[test.cpp:2] -> [test.cpp:3]: (warning) Either the condition 'v.empty()' is redundant or expression 'v.pop_back()' cause access out of bounds.\n",
3209
+
ASSERT_EQUALS("[test.cpp:2] -> [test.cpp:3]: (warning) Either the condition 'v.empty()' is redundant or expression 'v.pop_back()' causes access out of bounds.\n",
0 commit comments