Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
this ICE was caused by `transform_ty`
in compiler/rustc_symbol_mangling/src/typeid/typeid_itanium_cxx_abi.rs
encountering an unevaluated const, while expecting it to already be evaluated.

add a regression test

Update tests/ui/sanitize/issue-114275-cfi-const-expr-in-arry-len.rs

Co-authored-by: Michael Goulet <michael@errs.io>

Update tests/ui/sanitize/issue-114275-cfi-const-expr-in-arry-len.rs

Co-authored-by: Michael Goulet <michael@errs.io>
  • Loading branch information
lenawanel and compiler-errors committed Aug 9, 2023
1 parent 27a43f0 commit 6394d88
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -824,11 +824,8 @@ fn transform_ty<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>, options: TransformTyOptio
}

ty::Array(ty0, len) => {
let len = len
.try_to_scalar()
.unwrap()
.to_u64()
.unwrap_or_else(|_| panic!("failed to convert length to u64"));
let len = len.eval_target_usize(tcx, ty::ParamEnv::reveal_all());

ty = Ty::new_array(tcx, transform_ty(tcx, *ty0, options), len);
}

Expand Down
15 changes: 15 additions & 0 deletions tests/ui/sanitize/issue-114275-cfi-const-expr-in-arry-len.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Regression test for issue 114275 `typeid::typeid_itanium_cxx_abi::transform_ty`
// was expecting array type lengths to be evaluated, this was causing an ICE.
//
// build-pass
// compile-flags: -Ccodegen-units=1 -Clto -Zsanitizer=cfi
// needs-sanitizer-cfi

#![crate_type = "lib"]

#[repr(transparent)]
pub struct Array([u8; 1 * 1]);

pub extern "C" fn array() -> Array {
loop {}
}

0 comments on commit 6394d88

Please sign in to comment.