Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Destructor is not called for AliasSeq (type tuple) #4427

Closed
JohanEngelen opened this issue Jun 22, 2023 · 2 comments
Closed

Destructor is not called for AliasSeq (type tuple) #4427

JohanEngelen opened this issue Jun 22, 2023 · 2 comments

Comments

@JohanEngelen
Copy link
Member

Testcase:

import core.stdc.stdio: printf;
alias AliasSeq(TList...) = TList;

int i = 0;
struct A {
    ~this() {
        i++;
    }
}

void main() {
    {
	    AliasSeq!(A, A) params;
    }
    printf("%d\n", i); // prints 0 !
    assert(i == 2); // fails!
}

https://godbolt.org/z/TGMWczh3E

-vcg-ast output shows the problem that the frontend does not add destructors calls like it usually does:

void main()
{
	{
		(A, A) params;
               //  there should be two explicit destructors calls here (~this())
	}
	printf("%d\n", i);
	assert(i == 2);
	return 0;
}
@kinke
Copy link
Member

kinke commented Nov 6, 2023

This was fixed in the frontend, right?

@JohanEngelen
Copy link
Member Author

Yep, fixed in LDC 1.35.0

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

No branches or pull requests

2 participants