Skip to content

[REG master] hasElaborateDestructor fails with private destructor #22609

Closed

Description

@tim-dlang
struct S
{
    private ~this();
}

void f()
{
    auto x = new S;
}

Since commit 0d626a0 this fails with the following message:

druntime/import/core/lifetime.d(3016): Error: template instance `core.internal.traits.hasElaborateDestructor!(S)` error instantiating
    enum TypeInfoSize = (is (T == struct) && hasElaborateDestructor!T) ? size_t.sizeof : 0;
                                             ^
druntime/import/core/lifetime.d(2834):        instantiated from here: `TypeInfoSize!(S)`
    if (TypeInfoSize!T)
        ^
testprivatedestructor.d(8):        instantiated from here: `_d_newitemT!(S)`
    auto x = new S;
             ^

Activity

  1. ntrel commented on Feb 23, 2026

    @ntrel
    Contributor

    druntime/import/core/lifetime.d(3016): Error: template instance core.internal.traits.hasElaborateDestructor!(S) error instantiating

    I'm not sure why that error happened. S has a private __xdtor, but when wrapping S in S2, S2 should still be able to access its own __xdtor. Anyway, due to all the problems I've made a PR to add a compiler trait instead.

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

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