File tree 2 files changed +9
-6
lines changed
2 files changed +9
-6
lines changed Original file line number Diff line number Diff line change 23
23
#![ feature( const_ptr_offset) ]
24
24
#![ feature( const_trait_impl) ]
25
25
#![ feature( const_likely) ]
26
+ #![ feature( core_ffi_c) ]
26
27
#![ feature( core_intrinsics) ]
27
28
#![ feature( core_private_bignum) ]
28
29
#![ feature( core_private_diy_float) ]
Original file line number Diff line number Diff line change @@ -289,16 +289,18 @@ fn test_const_nonnull_new() {
289
289
}
290
290
291
291
#[ test]
292
- #[ allow( warnings) ]
293
- // Have a symbol for the test below. It doesn’t need to be an actual variadic function, match the
294
- // ABI, or even point to an actual executable code, because the function itself is never invoked.
295
- #[ no_mangle]
292
+ #[ cfg( unix) ] // printf may not be available on other platforms
293
+ #[ allow( deprecated) ] // For SipHasher
296
294
pub fn test_variadic_fnptr ( ) {
295
+ use core:: ffi;
297
296
use core:: hash:: { Hash , SipHasher } ;
298
297
extern "C" {
299
- fn test_variadic_fnptr ( _: u64 , ...) -> f64 ;
298
+ // This needs to use the correct function signature even though it isn't called as some
299
+ // codegen backends make it UB to declare a function with multiple conflicting signatures
300
+ // (like LLVM) while others straight up return an error (like Cranelift).
301
+ fn printf ( _: * const ffi:: c_char , ...) -> ffi:: c_int ;
300
302
}
301
- let p: unsafe extern "C" fn ( u64 , ...) -> f64 = test_variadic_fnptr ;
303
+ let p: unsafe extern "C" fn ( * const ffi :: c_char , ...) -> ffi :: c_int = printf ;
302
304
let q = p. clone ( ) ;
303
305
assert_eq ! ( p, q) ;
304
306
assert ! ( !( p < q) ) ;
You can’t perform that action at this time.
0 commit comments