let cast_loc_to_loc ty1 ty2 l =
    let o1 = object_of ty1 in 
    let o2 = object_of ty2 in 
   if Ctypes.equal o1 o2 then l else
     match o1,o2 with 
       | C_array ar, C_pointer ty2 ->
           if Ctypes.equal (Ctypes.object_of ar.arr_element) (Ctypes.object_of ty2) then 
             l 
           else 
             (match  ar.arr_flat with 
                | Some {Ctypes.arr_cell = ty1} ->
                    if Ctypes.equal (Ctypes.object_of ty1) (Ctypes.object_of ty2) 
                    then l 
                    else (unsupported "pointer cast from %a to %a "
                            !Ast_printer.d_type ty1
                            !Ast_printer.d_type ty2)
                | None -> (unsupported "pointer cast from %a to %a "
                             !Ast_printer.d_type ty1
                             !Ast_printer.d_type ty2)
             )
       | _,_ -> (unsupported "pointer cast from %a to %a "
                   !Ast_printer.d_type ty1
                   !Ast_printer.d_type ty2)