[inferbo] Suppress exception on placement new

Summary:
It avoids raising an exception when unexpected arguments are given to
placement new.  We will revert this after fixing the frontend to parse
user defined `new` correctly in the future.

Reviewed By: mbouaziz

Differential Revision: D10378136

fbshipit-source-id: d494f781b
master
Sungkeun Cho 6 years ago committed by Facebook Github Bot
parent 2e64566a6c
commit fd660f42f5

@ -186,7 +186,10 @@ let placement_new size_exp (src_exp1, t1) src_arg2_opt =
| Some (src_exp2, t2) when Typ.is_pointer_to_void t2 ->
src_exp2
| _ ->
L.(die InternalError) "Unexpected types of arguments for __placement_new"
(* TODO: Raise an exception when given unexpected arguments. Before that, we need
to fix the frontend to parse user defined `new` correctly. *)
L.(debug BufferOverrun Verbose) "Unexpected types of arguments for __placement_new" ;
src_exp1
in
let v = Sem.eval src_exp mem in
Dom.Mem.add_stack (Loc.of_id id) v mem

@ -131,6 +131,20 @@ void placement_new_overload4_Good() {
x->a[0] = 0;
}
struct Allocator {
void* allocate(std::size_t size) { return malloc(size); }
};
void* operator new(std::size_t size, Allocator& allocator) {
return allocator.allocate(size);
}
void user_defined_new_Bad_FN() {
Allocator allocator;
my_class2* x = new (allocator) my_class2();
x->a[10] = 0;
}
class my_class4 {
public:
int a[3];

Loading…
Cancel
Save