Skip to content

Instantly share code, notes, and snippets.

@jld
Last active December 12, 2015 09:08
Show Gist options
  • Select an option

  • Save jld/4748858 to your computer and use it in GitHub Desktop.

Select an option

Save jld/4748858 to your computer and use it in GitHub Desktop.
Alignment: it gets worse.
enum NewType<T> = T;
struct AfterByte<T> { a: u8, b: T }
const C0: AfterByte<u32> = AfterByte { a: 0xA5, b: 0xDEADBEEF };
const C1: AfterByte<NewType<u32>> = AfterByte { a: 0xA5, b: NewType(0xDEADBEEF) };
fn main() {
io::println(fmt!("C0.b = %x", C0.b as uint));
io::println(fmt!("C1.b = %x", *(C1.b) as uint));
}
// Expected output:
// C0.b = deadbeef
// C1.b = deadbeef
// Actual output (little-endian):
// C0.b = deadbeef
// C1.b = ef000000
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment