File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -165,6 +165,7 @@ class TestBufferOverrun : public TestFixture {
165165 TEST_CASE (array_index_75);
166166 TEST_CASE (array_index_76);
167167 TEST_CASE (array_index_77);
168+ TEST_CASE (array_index_78);
168169 TEST_CASE (array_index_multidim);
169170 TEST_CASE (array_index_switch_in_for);
170171 TEST_CASE (array_index_for_in_for); // FP: #2634
@@ -2031,6 +2032,22 @@ class TestBufferOverrun : public TestFixture {
20312032 errout_str ());
20322033 }
20332034
2035+ void array_index_78 ()
2036+ {
2037+ check (" void f() {\n "
2038+ " struct {\n "
2039+ " int a; \n "
2040+ " void set(int i) { a = i; }\n "
2041+ " } v[4];\n "
2042+ " int idx = 0;\n "
2043+ " v[idx++].set(0);\n "
2044+ " v[idx++].set(0);\n "
2045+ " v[idx++].set(0);\n "
2046+ " v[idx++].set(0);\n "
2047+ " }\n " );
2048+ ASSERT_EQUALS (" " , errout_str ());
2049+ }
2050+
20342051 void array_index_multidim () {
20352052 check (" void f()\n "
20362053 " {\n "
Original file line number Diff line number Diff line change @@ -1019,6 +1019,19 @@ class TestStl : public TestFixture {
10191019 " return outStr;\n "
10201020 " }\n " );
10211021 ASSERT_EQUALS (" " , errout_str ());
1022+
1023+ checkNormal (" struct S {\n " // #12731
1024+ " void f(int j = 0) { a = j; }\n "
1025+ " int a;\n "
1026+ " };\n "
1027+ " std::vector<S*> g() {\n "
1028+ " int i = 0;\n "
1029+ " std::vector<S*> v;\n "
1030+ " v.push_back(new S());\n "
1031+ " v[i++].f(1);\n "
1032+ " return v;\n "
1033+ " }\n " );
1034+ ASSERT_EQUALS (" " , errout_str ());
10221035 }
10231036
10241037 void outOfBoundsSymbolic ()
You can’t perform that action at this time.
0 commit comments