Skip to content

MSVC++ interop: Missing special cases for struct PODness #5139

Description

@kinke

MS(VC++) is weird; our PODness logic is incomplete - so far, only the special case that any constructor makes a struct a non-POD is handled:

ldc/gen/abi/abi.cpp

Lines 119 to 125 in b996d14

bool TargetABI::isPOD(Type *t, bool excludeStructsWithCtor) {
t = t->baseElemOf();
if (t->ty != TY::Tstruct)
return true;
StructDeclaration *sd = static_cast<TypeStruct *>(t)->sym;
return dmd::isPOD(sd) && !(excludeStructsWithCtor && sd->ctor);
}

Non-public data fields seem to make a struct a non-POD too: #5113 (comment). Not sure if Microsoft had any more great ideas for special cases.

I bet DMD doesn't handle this either. Extending the upstream runnable_cxx/{cppa.d,extra-files/cppb.cpp} tests with the special-struct cases would be good, using a small struct <= 8 bytes which would otherwise be passed/returned in a register.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions