As I pointed out, your drop_new is broken for copyable types. For example, consider std::array:
auto w = std::array<int, 3>{0, 1, 2}; drop_new(std::move(w)); std::cerr << w[0] << ", " << w[1] << ", " << w[2] << '\n';
> And yes, the compiler will not prevent you from using this value.
Yes, that is the point!
This bit:
std::vector<int> vec {1, 2, 3}; drop_new(std::move(vec)); std::cerr << vec.size() << " <- ?\n";
let vec = vec![1, 2, 3]; drop(vec); println!("{0} <- ?", vec.len()); // error[E0382]: borrow of moved value: `vec`
> But clang static analyzer will happily detect it.
One problem is that you're not guaranteed to catch it, similarly to why static analyzers aren't guaranteed to catch use-after-frees.
As I pointed out, your drop_new is broken for copyable types. For example, consider std::array:
This prints "0, 1, 2". Rust's drop() doesn't suffer from this flaw.> And yes, the compiler will not prevent you from using this value.
Yes, that is the point!
This bit:
Simply does not compile in Rust [0]: [0]: https://rust.godbolt.org/z/GjcMYnEzq> But clang static analyzer will happily detect it.
One problem is that you're not guaranteed to catch it, similarly to why static analyzers aren't guaranteed to catch use-after-frees.