Skip to content

Commit c21d6cf

Browse files
committed
Add xazax-hun's placement new tests
1 parent e14945b commit c21d6cf

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

clang/test/Analysis/initializer.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,14 @@ void aggregate_struct() {
462462
::new (&di) S;
463463
int z = di.x + 1; // expected-warning{{The left operand of '+' is a garbage value}}
464464
}
465+
void initialize_non_zeroth_element(S arr[2]) {
466+
new (&arr[1]) S{1};
467+
clang_analyzer_eval(1 == arr[1].x); // expected-warning{{TRUE}}
468+
}
469+
void initialize_non_zeroth_argument_pointers(S *arr[2]) {
470+
arr[1] = new (arr[1]) S{1};
471+
clang_analyzer_eval(1 == arr[1]->x); // expected-warning{{TRUE}}
472+
}
465473
} // namespace initializer_list_arg
466474

467475
namespace CXX17_transparent_init_list_exprs {

0 commit comments

Comments
 (0)