From 52cf61fd3bf928de5ca56957e5e1a2dc88d10848 Mon Sep 17 00:00:00 2001 From: Jed Davis Date: Wed, 30 Jan 2013 15:17:23 -0800 Subject: [PATCH] Fix const enums better: let them have the same alignment as an "opaque enum". --- src/librustc/middle/trans/consts.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/librustc/middle/trans/consts.rs b/src/librustc/middle/trans/consts.rs index 34f1f1f2314..f24ea04569c 100644 --- a/src/librustc/middle/trans/consts.rs +++ b/src/librustc/middle/trans/consts.rs @@ -470,7 +470,12 @@ pub fn const_expr(cx: @crate_ctxt, e: @ast::expr) -> ValueRef { // FIXME (#1645): enum body alignment is generaly wrong. if !degen { - C_packed_struct(~[discrim, c_args]) + // A packed_struct has an alignment of 1; thus, + // wrapping one around c_args will misalign it the + // same way we normally misalign enum bodies + // without affecting its internal alignment or + // changing the alignment of the enum. + C_struct(~[discrim, C_packed_struct(~[c_args])]) } else if size == 0 { C_struct(~[discrim]) } else {