Skip to content

Commit b6fe7b5

Browse files
committed
Add a set of compliant cases and update test results
1 parent c3ae6e8 commit b6fe7b5

File tree

2 files changed

+62
-40
lines changed

2 files changed

+62
-40
lines changed

cpp/misra/test/rules/RULE-21-6-3/AdvancedMemoryManagementUsed.expected

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -46,43 +46,43 @@
4646
| test.cpp:168:6:168:20 | declaration of operator delete | User-provided declaration of `operator delete`. |
4747
| test.cpp:171:6:171:22 | declaration of operator delete[] | User-provided declaration of `operator delete[]`. |
4848
| test.cpp:174:6:174:20 | definition of operator delete | User-provided declaration of `operator delete`. |
49-
| test.cpp:184:12:184:26 | call to operator new | Call to banned function `operator new` which is a non-replaceable allocation function. |
50-
| test.cpp:185:12:186:10 | call to operator new | Call to banned function `operator new` which is a non-replaceable allocation function. |
51-
| test.cpp:190:7:190:31 | call to operator new[] | Call to banned function `operator new[]` which is a non-replaceable allocation function. |
52-
| test.cpp:193:12:193:23 | call to operator new | Call to banned function `operator new` which is a non-replaceable allocation function. |
53-
| test.cpp:200:12:200:22 | call to operator new | Call to banned function `operator new` which is a non-replaceable allocation function. |
54-
| test.cpp:202:7:202:22 | call to operator new | Call to banned function `operator new` which is a non-replaceable allocation function. |
55-
| test.cpp:224:7:224:21 | operator new | Taking the address of a banned function `operator new` which is a non-replaceable allocation function. |
56-
| test.cpp:226:7:226:20 | operator new | Taking the address of a banned function `operator new` which is a non-replaceable allocation function. |
57-
| test.cpp:228:7:228:23 | operator new[] | Taking the address of a banned function `operator new[]` which is a non-replaceable allocation function. |
58-
| test.cpp:230:7:230:22 | operator new[] | Taking the address of a banned function `operator new[]` which is a non-replaceable allocation function. |
59-
| test.cpp:257:7:257:24 | operator delete | Taking the address of a banned function `operator delete` which is a non-replaceable deallocation function. |
60-
| test.cpp:259:7:259:23 | operator delete | Taking the address of a banned function `operator delete` which is a non-replaceable deallocation function. |
61-
| test.cpp:261:7:261:26 | operator delete[] | Taking the address of a banned function `operator delete[]` which is a non-replaceable deallocation function. |
62-
| test.cpp:263:7:263:25 | operator delete[] | Taking the address of a banned function `operator delete[]` which is a non-replaceable deallocation function. |
63-
| test.cpp:281:7:281:23 | operator new | Taking the address of a banned function `operator new` which is a non-replaceable allocation function. |
64-
| test.cpp:284:7:284:23 | operator new | Taking the address of a banned function `operator new` which is a non-replaceable allocation function. |
65-
| test.cpp:298:7:298:26 | operator delete | Taking the address of a banned function `operator delete` which is a non-replaceable deallocation function. |
66-
| test.cpp:301:7:301:28 | operator delete[] | Taking the address of a banned function `operator delete[]` which is a non-replaceable deallocation function. |
67-
| test.cpp:304:7:304:26 | operator delete | Taking the address of a banned function `operator delete` which is a non-replaceable deallocation function. |
68-
| test.cpp:318:3:318:38 | call to uninitialized_default_construct | Call to banned function `uninitialized_default_construct` which is a function from <memory> that manages uninitialized memory. |
69-
| test.cpp:319:3:319:40 | call to uninitialized_default_construct_n | Call to banned function `uninitialized_default_construct_n` which is a function from <memory> that manages uninitialized memory. |
70-
| test.cpp:332:3:332:36 | call to uninitialized_value_construct | Call to banned function `uninitialized_value_construct` which is a function from <memory> that manages uninitialized memory. |
71-
| test.cpp:333:3:333:38 | call to uninitialized_value_construct_n | Call to banned function `uninitialized_value_construct_n` which is a function from <memory> that manages uninitialized memory. |
72-
| test.cpp:345:3:345:25 | call to uninitialized_copy | Call to banned function `uninitialized_copy` which is a function from <memory> that manages uninitialized memory. |
73-
| test.cpp:346:3:346:27 | call to uninitialized_copy_n | Call to banned function `uninitialized_copy_n` which is a function from <memory> that manages uninitialized memory. |
74-
| test.cpp:358:3:358:25 | call to uninitialized_move | Call to banned function `uninitialized_move` which is a function from <memory> that manages uninitialized memory. |
75-
| test.cpp:359:3:359:27 | call to uninitialized_move_n | Call to banned function `uninitialized_move_n` which is a function from <memory> that manages uninitialized memory. |
76-
| test.cpp:372:3:372:25 | call to uninitialized_fill | Call to banned function `uninitialized_fill` which is a function from <memory> that manages uninitialized memory. |
77-
| test.cpp:373:3:373:27 | call to uninitialized_fill_n | Call to banned function `uninitialized_fill_n` which is a function from <memory> that manages uninitialized memory. |
78-
| test.cpp:385:3:385:38 | call to uninitialized_default_construct | Call to banned function `uninitialized_default_construct` which is a function from <memory> that manages uninitialized memory. |
79-
| test.cpp:387:3:387:14 | call to destroy | Call to banned function `destroy` which is a function from <memory> that manages uninitialized memory. |
80-
| test.cpp:388:3:388:16 | call to destroy_n | Call to banned function `destroy_n` which is a function from <memory> that manages uninitialized memory. |
81-
| test.cpp:389:3:389:17 | call to destroy_at | Call to banned function `destroy_at` which is a function from <memory> that manages uninitialized memory. |
82-
| test.cpp:397:12:397:26 | call to operator new | Call to banned function `operator new` which is a non-replaceable allocation function. |
83-
| test.cpp:398:3:398:11 | (vacuous destructor call) | Manual call to a destructor. |
84-
| test.cpp:399:12:399:26 | call to operator new | Call to banned function `operator new` which is a non-replaceable allocation function. |
85-
| test.cpp:401:12:401:23 | call to launder | Call to banned function `launder` which is a function from <memory> that manages uninitialized memory. |
86-
| test.cpp:411:3:411:10 | (vacuous destructor call) | Manual call to a destructor. |
87-
| test.cpp:421:3:421:11 | (vacuous destructor call) | Manual call to a destructor. |
88-
| test.cpp:432:5:432:16 | (vacuous destructor call) | Manual call to a destructor. |
49+
| test.cpp:206:12:206:26 | call to operator new | Call to banned function `operator new` which is a non-replaceable allocation function. |
50+
| test.cpp:207:12:208:10 | call to operator new | Call to banned function `operator new` which is a non-replaceable allocation function. |
51+
| test.cpp:212:7:212:31 | call to operator new[] | Call to banned function `operator new[]` which is a non-replaceable allocation function. |
52+
| test.cpp:215:12:215:23 | call to operator new | Call to banned function `operator new` which is a non-replaceable allocation function. |
53+
| test.cpp:222:12:222:22 | call to operator new | Call to banned function `operator new` which is a non-replaceable allocation function. |
54+
| test.cpp:224:7:224:22 | call to operator new | Call to banned function `operator new` which is a non-replaceable allocation function. |
55+
| test.cpp:246:7:246:21 | operator new | Taking the address of a banned function `operator new` which is a non-replaceable allocation function. |
56+
| test.cpp:248:7:248:20 | operator new | Taking the address of a banned function `operator new` which is a non-replaceable allocation function. |
57+
| test.cpp:250:7:250:23 | operator new[] | Taking the address of a banned function `operator new[]` which is a non-replaceable allocation function. |
58+
| test.cpp:252:7:252:22 | operator new[] | Taking the address of a banned function `operator new[]` which is a non-replaceable allocation function. |
59+
| test.cpp:279:7:279:24 | operator delete | Taking the address of a banned function `operator delete` which is a non-replaceable deallocation function. |
60+
| test.cpp:281:7:281:23 | operator delete | Taking the address of a banned function `operator delete` which is a non-replaceable deallocation function. |
61+
| test.cpp:283:7:283:26 | operator delete[] | Taking the address of a banned function `operator delete[]` which is a non-replaceable deallocation function. |
62+
| test.cpp:285:7:285:25 | operator delete[] | Taking the address of a banned function `operator delete[]` which is a non-replaceable deallocation function. |
63+
| test.cpp:303:7:303:23 | operator new | Taking the address of a banned function `operator new` which is a non-replaceable allocation function. |
64+
| test.cpp:306:7:306:23 | operator new | Taking the address of a banned function `operator new` which is a non-replaceable allocation function. |
65+
| test.cpp:320:7:320:26 | operator delete | Taking the address of a banned function `operator delete` which is a non-replaceable deallocation function. |
66+
| test.cpp:323:7:323:28 | operator delete[] | Taking the address of a banned function `operator delete[]` which is a non-replaceable deallocation function. |
67+
| test.cpp:326:7:326:26 | operator delete | Taking the address of a banned function `operator delete` which is a non-replaceable deallocation function. |
68+
| test.cpp:340:3:340:38 | call to uninitialized_default_construct | Call to banned function `uninitialized_default_construct` which is a function from <memory> that manages uninitialized memory. |
69+
| test.cpp:341:3:341:40 | call to uninitialized_default_construct_n | Call to banned function `uninitialized_default_construct_n` which is a function from <memory> that manages uninitialized memory. |
70+
| test.cpp:354:3:354:36 | call to uninitialized_value_construct | Call to banned function `uninitialized_value_construct` which is a function from <memory> that manages uninitialized memory. |
71+
| test.cpp:355:3:355:38 | call to uninitialized_value_construct_n | Call to banned function `uninitialized_value_construct_n` which is a function from <memory> that manages uninitialized memory. |
72+
| test.cpp:367:3:367:25 | call to uninitialized_copy | Call to banned function `uninitialized_copy` which is a function from <memory> that manages uninitialized memory. |
73+
| test.cpp:368:3:368:27 | call to uninitialized_copy_n | Call to banned function `uninitialized_copy_n` which is a function from <memory> that manages uninitialized memory. |
74+
| test.cpp:380:3:380:25 | call to uninitialized_move | Call to banned function `uninitialized_move` which is a function from <memory> that manages uninitialized memory. |
75+
| test.cpp:381:3:381:27 | call to uninitialized_move_n | Call to banned function `uninitialized_move_n` which is a function from <memory> that manages uninitialized memory. |
76+
| test.cpp:394:3:394:25 | call to uninitialized_fill | Call to banned function `uninitialized_fill` which is a function from <memory> that manages uninitialized memory. |
77+
| test.cpp:395:3:395:27 | call to uninitialized_fill_n | Call to banned function `uninitialized_fill_n` which is a function from <memory> that manages uninitialized memory. |
78+
| test.cpp:407:3:407:38 | call to uninitialized_default_construct | Call to banned function `uninitialized_default_construct` which is a function from <memory> that manages uninitialized memory. |
79+
| test.cpp:409:3:409:14 | call to destroy | Call to banned function `destroy` which is a function from <memory> that manages uninitialized memory. |
80+
| test.cpp:410:3:410:16 | call to destroy_n | Call to banned function `destroy_n` which is a function from <memory> that manages uninitialized memory. |
81+
| test.cpp:411:3:411:17 | call to destroy_at | Call to banned function `destroy_at` which is a function from <memory> that manages uninitialized memory. |
82+
| test.cpp:419:12:419:26 | call to operator new | Call to banned function `operator new` which is a non-replaceable allocation function. |
83+
| test.cpp:420:3:420:11 | (vacuous destructor call) | Manual call to a destructor. |
84+
| test.cpp:421:12:421:26 | call to operator new | Call to banned function `operator new` which is a non-replaceable allocation function. |
85+
| test.cpp:423:12:423:23 | call to launder | Call to banned function `launder` which is a function from <memory> that manages uninitialized memory. |
86+
| test.cpp:433:3:433:10 | (vacuous destructor call) | Manual call to a destructor. |
87+
| test.cpp:443:3:443:11 | (vacuous destructor call) | Manual call to a destructor. |
88+
| test.cpp:454:5:454:16 | (vacuous destructor call) | Manual call to a destructor. |

cpp/misra/test/rules/RULE-21-6-3/test.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,28 @@ void operator delete(void *ptr, int hint) noexcept {
175175
std::free(ptr);
176176
} // NON_COMPLIANT: custom parameter
177177

178+
/**
179+
* Test replaceable new / delete expressions.
180+
*/
181+
void use_standard_new_delete() {
182+
// Compliant: new expressions that call the global `operator new`s.
183+
struct S {};
184+
S *p1 = new S; // COMPLIANT
185+
S *p2 = new S[10]; // COMPLIANT
186+
void *p3 = ::operator new(sizeof(S));
187+
void *p4 = ::operator new[](sizeof(S));
188+
S *p5 = new (std::nothrow) S; // COMPLIANT
189+
S *p6 = new (std::nothrow) S[10]; // COMPLIANT
190+
191+
// Compliant: delete expressions that call the global `operator delete`s.
192+
delete p1; // COMPLIANT
193+
delete[] p2; // COMPLIANT
194+
::operator delete(p3); // COMPLIANT
195+
::operator delete[](p4); // COMPLIANT
196+
::operator delete(p5, std::nothrow); // COMPLIANT
197+
::operator delete[](p6, std::nothrow); // COMPLIANT
198+
}
199+
178200
/**
179201
* Test placement new expressions.
180202
*/

0 commit comments

Comments
 (0)