Skip to content

Commit c3b8295

Browse files
committed
test
1 parent c83bee7 commit c3b8295

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

‎test/testother.cpp‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff 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() {

0 commit comments

Comments
 (0)