Skip to content

Commit 8527c7f

Browse files
committed
Fix transmutes with boolean source values
Fixes #25746
1 parent 860448f commit 8527c7f

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

src/librustc_trans/trans/intrinsic.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ pub fn trans_intrinsic_call<'a, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
223223
let val = if datum.kind.is_by_ref() {
224224
load_ty(bcx, datum.val, datum.ty)
225225
} else {
226-
datum.val
226+
from_arg_ty(bcx, datum.val, datum.ty)
227227
};
228228

229229
let cast_val = BitCast(bcx, val, llret_ty);
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
use std::mem::transmute;
12+
13+
fn main() {
14+
unsafe {
15+
let _: i8 = transmute(false);
16+
let _: i8 = transmute(true);
17+
let _: bool = transmute(0u8);
18+
let _: bool = transmute(1u8);
19+
}
20+
}

0 commit comments

Comments
 (0)