d90830221e
Closes #8506. The `trans::adt` code for statics uses fields with `C_undef` values to insert alignment padding (because LLVM's own alignment padding isn't always sufficient for aggregate constants), and assumes that all fields in the actual Rust value are represented by non-undef LLVM values, to distinguish them from that padding. But for nullable pointer enums, if non-null variant has fields other than the pointer used as the discriminant, they would be set to undef in the null case, to reflect that they're never accessed. To avoid the obvious conflict between these two items, the latter undefs were wrapped in unary LLVM structs to distinguish them from the former undefs. Except this doesn't actually work -- LLVM, not unreasonably, treats the "wrapped undef" as a regular undef. So this commit just sets all fields to null in the null pointer case of a nullable pointer enum static, because the other fields don't really need to be undef in the first place.
21 lines
588 B
Rust
21 lines
588 B
Rust
// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT
|
|
// file at the top-level directory of this distribution and at
|
|
// http://rust-lang.org/COPYRIGHT.
|
|
//
|
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
// option. This file may not be copied, modified, or distributed
|
|
// except according to those terms.
|
|
|
|
#[allow(dead_code)];
|
|
|
|
enum Either {
|
|
One,
|
|
Other(~str,~str)
|
|
}
|
|
|
|
static one : Either = One;
|
|
|
|
pub fn main () { }
|