Skip to content

Delegation makes it possible to define C-variadic associated functions #127413

Closed
@fmease

Description

@fmease

While the following code gets rejected:

#![feature(c_variadic)]

struct S;

impl S {
    unsafe extern "C" fn f(...) {}
    //~^ ERROR only foreign, `unsafe extern "C"`, or `unsafe extern "C-unwind"` functions may have a C-variadic arg
}

The code below doesn't:

#![feature(c_variadic, fn_delegation)]

struct S;

unsafe extern "C" fn f(...) {}

impl S {
    reuse f;
}

And yes, S::f does "appear to behave variadic". I'm not a C-FFI or ABI expert, so I guess it's for a very good reason that variadic associated functions generally get rejected.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.F-c_variadic`#![feature(c_variadic)]`F-fn_delegation`#![feature(fn_delegation)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.requires-incomplete-featuresThis issue requires the use of incomplete features.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions