about summary refs log tree commit diff
diff options
context:
space:
mode:
authorRalf Jung <post@ralfj.de>2021-12-06 17:58:24 -0500
committerRalf Jung <post@ralfj.de>2021-12-20 22:37:14 +0100
commita97f41fd693d93d3afc91e8955ec308f9f157f73 (patch)
treee6586d7bef5c6c71ff1500dafac050bffc5d63ba
parentb81553267437627af63c79c1a20c73af865a842a (diff)
downloadrust-a97f41fd693d93d3afc91e8955ec308f9f157f73.tar.gz
rust-a97f41fd693d93d3afc91e8955ec308f9f157f73.zip
don't ICE on variadic function calls
-rw-r--r--compiler/rustc_const_eval/src/interpret/terminator.rs11
1 files changed, 9 insertions, 2 deletions
diff --git a/compiler/rustc_const_eval/src/interpret/terminator.rs b/compiler/rustc_const_eval/src/interpret/terminator.rs
index 27f6a75ebe8..f3910c9765d 100644
--- a/compiler/rustc_const_eval/src/interpret/terminator.rs
+++ b/compiler/rustc_const_eval/src/interpret/terminator.rs
@@ -331,8 +331,15 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
                 // `find_mir_or_eval_fn`.
                 // FIXME: for variadic support, do we have to somehow determine calle's extra_args?
                 let callee_fn_abi = self.fn_abi_of_instance(instance, ty::List::empty())?;
-                assert!(!callee_fn_abi.c_variadic);
-                assert!(!caller_fn_abi.c_variadic);
+
+                if callee_fn_abi.c_variadic != caller_fn_abi.c_variadic {
+                    throw_ub_format!(
+                        "calling a c-variadic function via a non-variadic call site, or vice versa"
+                    );
+                }
+                if callee_fn_abi.c_variadic {
+                    throw_unsup_format!("calling a c-variadic function is not supported");
+                }
 
                 if M::enforce_abi(self) {
                     if caller_fn_abi.conv != callee_fn_abi.conv {