Fix max_sz bug that ended up causing us to index incorrectly into a vec of tag types. Add a testcase.
This commit is contained in:
parent
6bce296d9f
commit
4e376852e7
3 changed files with 20 additions and 1 deletions
|
|
@ -507,6 +507,7 @@ TEST_XFAILS_LLVM := $(TASK_XFAILS) \
|
|||
rec-tup.rs \
|
||||
rec.rs \
|
||||
simple-obj.rs \
|
||||
size-and-align.rs \
|
||||
spawn-fn.rs \
|
||||
spawn-module-qualified.rs \
|
||||
spawn.rs \
|
||||
|
|
|
|||
|
|
@ -686,7 +686,7 @@ let rec max_sz (a:size) (b:size) : size =
|
|||
| (SIZE_rt_max (b, c), a) when a = c -> max_sz a b
|
||||
| (SIZE_fixed a, SIZE_fixed b) -> SIZE_fixed (i64_max a b)
|
||||
| (SIZE_fixed 0L, b) when no_negs b -> b
|
||||
| (a, SIZE_fixed 0L) when no_negs a -> b
|
||||
| (a, SIZE_fixed 0L) when no_negs a -> a
|
||||
| (a, SIZE_fixed b) -> max_sz (SIZE_fixed b) a
|
||||
| (a, b) when a = b -> a
|
||||
| (a, b) -> SIZE_rt_max (a, b)
|
||||
|
|
|
|||
18
src/test/run-pass/size-and-align.rs
Normal file
18
src/test/run-pass/size-and-align.rs
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
// -*- rust -*-
|
||||
|
||||
use std;
|
||||
import std._vec;
|
||||
|
||||
type clam[T] = tag(a(T, int), b());
|
||||
|
||||
fn uhoh[T](vec[clam[T]] v) {
|
||||
alt (v.(1)) {
|
||||
case (a[T](t, u)) { log "incorrect"; log u; fail; }
|
||||
case (b[T]()) { log "correct"; }
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let vec[clam[int]] v = vec(b[int](), b[int](), a[int](42, 17));
|
||||
uhoh[int](v);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue