File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -10070,6 +10070,22 @@ class TestOther : public TestFixture {
1007010070 ASSERT_EQUALS(
1007110071 "[test.cpp:2:9]: (style) Variable 'ptr' can be declared as pointer to const [constVariablePointer]\n",
1007210072 errout_str());
10073+
10074+ check("void f() {\n"
10075+ " char *p = new char[1];\n"
10076+ " ++p;\n"
10077+ " delete [] (p - 1);\n"
10078+ "}\n");
10079+ ASSERT_EQUALS("[test.cpp:2:11]: (style) Variable 'p' can be declared as pointer to const [constVariablePointer]\n",
10080+ errout_str());
10081+
10082+ check("void f() {\n"
10083+ " char *p = new char[1];\n"
10084+ " delete [] (p - 1);\n"
10085+ "}\n");
10086+ ASSERT_EQUALS("[test.cpp:2:11]: (style) Variable 'p' can be declared as pointer to const [constVariablePointer]\n"
10087+ "[test.cpp:3:5]: (error) Mismatching address is deleted. The address you get from new must be deleted without offset. [invalidFree]\n"
10088+ , errout_str());
1007310089 }
1007410090
1007510091 void checkRedundantCopy() {
You can’t perform that action at this time.
0 commit comments