graydon/rust — Issue #1023: Implicit return double-frees in some situations
Author: marijnh
Created: 2011-10-11 14:30:10+00:00
State: open

The function below (in trans.rs) works fine as long as the last clause contains `ret bcx;`. If this is changed to simply `bcx`, the compiler dies on a double free when compiling the standard lib. The form of the other clauses doesn't matter -- they work with or without the `ret`.

```
fn drop_ty_immediate(bcx: @block_ctxt, v: ValueRef, t: ty::t) -> @block_ctxt {
alt ty::struct(bcx_tcx(bcx), t) {
ty::ty_uniq(_) | ty::ty_vec(_) | ty::ty_str. {
ret free_ty(bcx, v, t);
}
ty::ty_box(_) { ret decr_refcnt_maybe_free(bcx, v, t); }
ty::ty_ptr(_) { bcx }
}
}
```

I haven't found a smaller program that produces the same issue yet.