Skip to content

Calls to C variadic functions are inlined by MIR inliner #78859

Closed

Description

#![feature(c_variadic)]

fn main() {
    let s = unsafe { sum(4u32, 4u32, 30u32, 200u32, 1000u32) };
    assert_eq!(s, 1234);
}

#[no_mangle]
#[inline(always)]
pub unsafe extern "C" fn sum(n: u32, mut vs: ...) -> u32 {
    let mut s = 0;
    let mut i = 0;
    while i != n {
        s += vs.arg::<u32>();
        i += 1;
    }
    s
}
$ rustc v.rs -Zmir-opt-level=2
error: internal compiler error: compiler/rustc_middle/src/mir/tcx.rs:84:25: deref projection of non-dereferenceable ty PlaceTy { ty: u32, variant_index: None }

@rustbot modify labels: +A-mir-opt, +A-mir-opt-inlining

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    A-mir-optArea: MIR optimizationsA-mir-opt-inliningArea: MIR inliningC-bugCategory: This is a bug.F-c_variadic`#![feature(c_variadic)]`T-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