mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-23 15:23:46 +00:00
Add a test for enum discriminant range overflow.
It causes an LLVM assertion for every host/target word-size combination on incoming at the time of this writing.
This commit is contained in:
parent
04ecab909a
commit
7b2b4faba8
@ -139,7 +139,6 @@ fn generic_fields_of(cx: @CrateContext, r: &Repr, sizing: bool)
|
||||
fn load_discr(bcx: block, scrutinee: ValueRef, min: int, max: int)
|
||||
-> ValueRef {
|
||||
let ptr = GEPi(bcx, scrutinee, [0, 0]);
|
||||
// XXX: write tests for the edge cases here
|
||||
if max + 1 == min {
|
||||
// i.e., if the range is everything. The lo==hi case would be
|
||||
// rejected by the LLVM verifier (it would mean either an
|
||||
|
31
src/test/run-pass/enum-discrim-range-overflow.rs
Normal file
31
src/test/run-pass/enum-discrim-range-overflow.rs
Normal file
@ -0,0 +1,31 @@
|
||||
// Copyright 2013 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.
|
||||
|
||||
pub enum E64 {
|
||||
H64 = 0x7FFF_FFFF_FFFF_FFFF,
|
||||
L64 = 0x8000_0000_0000_0000
|
||||
}
|
||||
pub enum E32 {
|
||||
H32 = 0x7FFF_FFFF,
|
||||
L32 = 0x8000_0000
|
||||
}
|
||||
|
||||
pub fn f(e64: E64, e32: E32) -> (bool,bool) {
|
||||
(match e64 {
|
||||
H64 => true,
|
||||
L64 => false
|
||||
},
|
||||
match e32 {
|
||||
H32 => true,
|
||||
L32 => false
|
||||
})
|
||||
}
|
||||
|
||||
pub fn main() { }
|
Loading…
Reference in New Issue
Block a user