Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 2 additions & 11 deletions compiler/rustc_const_eval/src/interpret/intrinsics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ pub(crate) enum MinMax {

/// Whether two types `T` and `U` are compatible when a value of type `T` is passed as a c-variadic
/// argument and read as a value of type `U`.
enum VarArgCompatible {
pub enum VarArgCompatible {
/// `T` and `U` are compatible, e.g.
///
/// - They're the same type.
Expand Down Expand Up @@ -829,15 +829,6 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
return interp_ok(());
}

// Types of different sizes can never be compatible.
if arg_mplace.layout.size != callee_type.size {
throw_ub_format!(
"va_arg type mismatch: requested `{}` is incompatible with next argument of type `{}`",
callee_ty,
caller_ty,
)
}

Comment on lines -832 to -840

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume this is removed because it's also checked by validate_c_variadic_compatible_ty which is unconditionally called right below?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes indeed.

match self.validate_c_variadic_compatible_ty(arg_mplace.layout.ty, callee_type.ty)? {
VarArgCompatible::Compatible => interp_ok(()),
VarArgCompatible::Incompatible => throw_ub_format!(
Expand Down Expand Up @@ -875,7 +866,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
/// - `T` and `U` are both pointers, and their target types are compatible.
/// - `T` is a pointer to [`std::ffi::c_void`] and `U` is a pointer to [`i8`] or [`u8`],
/// or vice versa.
fn validate_c_variadic_compatible_ty(
pub fn validate_c_variadic_compatible_ty(
&mut self,
caller_type: Ty<'tcx>,
callee_type: Ty<'tcx>,
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_const_eval/src/interpret/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ pub use self::intern::{
HasStaticRootDefId, InternError, InternKind, intern_const_alloc_for_constprop,
intern_const_alloc_recursive,
};
pub use self::intrinsics::VarArgCompatible;
pub use self::machine::{
AllocMap, Machine, MayLeak, RetagMode, ReturnAction, compile_time_machine,
};
Expand Down
Loading