diff options
| author | Ralf Jung <post@ralfj.de> | 2021-12-06 17:58:24 -0500 |
|---|---|---|
| committer | Ralf Jung <post@ralfj.de> | 2021-12-20 22:37:14 +0100 |
| commit | a97f41fd693d93d3afc91e8955ec308f9f157f73 (patch) | |
| tree | e6586d7bef5c6c71ff1500dafac050bffc5d63ba | |
| parent | b81553267437627af63c79c1a20c73af865a842a (diff) | |
| download | rust-a97f41fd693d93d3afc91e8955ec308f9f157f73.tar.gz rust-a97f41fd693d93d3afc91e8955ec308f9f157f73.zip | |
don't ICE on variadic function calls
| -rw-r--r-- | compiler/rustc_const_eval/src/interpret/terminator.rs | 11 |
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 { |
