Skip to content

x86_64 MSVC coretest::ptr::test_variadic_fnptr: "error LNK2019: unresolved external symbol" #36076

Closed
@hanna-kruppe

Description

@hanna-kruppe

I get a linker error when building coretest as part of the check step, or more specifically check-crate-std. The source of the problem is the test test_variadic_fnptr in src/coretest/ptr.rs, and the same error can be provoked by this self-contained program:

fn main() {
    extern "C" {
        fn printf(_: *const u8, ...);
    }
    let p: unsafe extern "C" fn(*const u8, ...) = printf;
    let _q = p.clone();
}

Some notes:

  • compiling with optimizations will inline the clone and subsequently eliminate all the code including the part taking the address of printf, and then it compiles just fine.
  • It appears related to being variadic, since fabs in place of printf worked just fine.
  • It doesn't matter whether I take the address of the function or call it.

Meta

Reproduced with a rustup-provided nightly from August 21 and with the current bootstrap compiler (beta-2016-08-17).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions