Skip to content

std::nullptr_t in aggregates does not follow ABI #41987

@llvmbot

Description

@llvmbot
Bugzilla Link 42642
Version unspecified
OS All
Reporter LLVM Bugzilla Contributor
CC @dwblaikie,@DougGregor,@zygoloid,@TNorthover

Extended Description

When you create a trivial aggregate containing std::nullptr_t, it does not get passed through RDI/RSI, but gets classified as a memory arg

E.g.:

struct MyVar1 {
    int x = 3;
    std::nullptr_t n = nullptr;
};

void Foo(MyVar1 x);

void CallMyVar1() {
    MyVar1 m;
    Foo(m);  // Sets up stack frame and passes as pointer / MEMORY
}

GCC does this correct.

More elaborate examples: https://gcc.godbolt.org/z/IxLudk

Metadata

Metadata

Assignees

No one assigned

    Labels

    ABIApplication Binary InterfacebugzillaIssues migrated from bugzillac++clang:codegenIR generation bugs: mangling, exceptions, etc.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions