(T); #[rustc_abi(debug)] extern "C" fn test2(_x: Wrap...">

extern "C" fn on sparc64 targets does not respect repr(transparent) · Issue #115336 · rust-lang/rust (original) (raw)

I tried the following code:

#![feature(rustc_attrs)]

#[rustc_abi(debug)] extern "C" fn test1(_x: [u8; 0]) {}

#[repr(transparent)] struct Wrap(T);

#[rustc_abi(debug)] extern "C" fn test2(_x: Wrap<[u8; 0]>) {}

When running this with --target sparc64-unknown-linux-gnu (using Miri), the first function reports an argument pass mode of

                   mode: Indirect {
                       attrs: ArgAttributes {
                           regular: NoAlias | NoCapture | NonNull | NoUndef,
                           arg_ext: None,
                           pointee_size: Size(0 bytes),
                           pointee_align: Some(
                               Align(1 bytes),
                           ),
                       },
                       extra_attrs: None,
                       on_stack: false,
                   },

but the 2nd function reports

                   mode: Cast(
                       CastTarget {
                           prefix: [
                               None,
                               None,
                               None,
                               None,
                               None,
                               None,
                               None,
                               None,
                           ],
                           rest: Uniform {
                               unit: Reg {
                                   kind: Integer,
                                   size: Size(8 bytes),
                               },
                               total: Size(0 bytes),
                           },
                           attrs: ArgAttributes {
                               regular: (empty),
                               arg_ext: None,
                               pointee_size: Size(0 bytes),
                               pointee_align: None,
                           },
                       },
                       false,
                   ),

I'm not an expert in interpreting PassMode, but Indirect and Cast are not compatible, are they?

Cc @bjorn3 @eddyb @psumbera