Skip to content

Commit

Permalink
librustc: Bump the offset when translating const structs. Closes rust…
Browse files Browse the repository at this point in the history
  • Loading branch information
pcwalton committed May 31, 2013
1 parent 3a3bf8b commit 40b4557
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/librustc/middle/trans/adt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,7 @@ fn build_const_struct(ccx: @CrateContext, st: &Struct, vals: &[ValueRef])
vals[i]
};
cfields.push(val);
offset += machine::llsize_of_alloc(ccx, llty) as u64
}

return cfields;
Expand Down
14 changes: 14 additions & 0 deletions src/test/run-pass/const-struct-offsets.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
enum Foo {
IntVal(i32),
Int64Val(i64)
}

struct Bar {
i: i32,
v: Foo
}

static bar: Bar = Bar { i: 0, v: IntVal(0) };

fn main() {}

1 comment on commit 40b4557

@pcwalton
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

r+

Please sign in to comment.