Skip to content

extern "C" fn on sparc64 targets does not respect repr(transparent) #115336

Open
@RalfJung

Description

@RalfJung

I tried the following code:

#![feature(rustc_attrs)]

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

#[repr(transparent)]
struct Wrap<T>(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

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-ABIArea: Concerning the application binary interface (ABI)A-FFIArea: Foreign function interface (FFI)I-unsoundIssue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/SoundnessO-SPARCTarget: SPARC processorsP-highHigh priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions