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

Default-define out-of-line dtors for types with fwd-declared unique_ptr members #1088

Merged
merged 2 commits into from
Jun 22, 2024

Conversation

jarzec
Copy link
Contributor

@jarzec jarzec commented May 29, 2024

Some of the node types in parse.h have std::unique_ptr of forward-declared types as members without having destructors deferred to when the pointed-to types are defined. If the default deleter is used this is IFNDR. Despite that, all compilers seem to have been compiling such code without problem. Only recently Clang >=15 with C++23 enabled started to raise errors in such situations. This is likely due to the added constexpr in the default deleter, which seemed to have change changed implementation decisions.

This PR adds out-of-line defaulted destructors for such cases to fix the possible compiler errors. It also enables a build test for Clang 18 with C++23 to ensure the solution works.

// Because a forward-declared type is used in a std::unique_ptr as a member an out-of-line dtor is necessary
// Because of the OOL dtor together with the fact that the copy ctor+operator are deleted
// the move ctor+operator need to be explicitly defaulted
// As a result the default constructor also needs to be explicitly defaulted
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an interesting side-effect of the changes.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good old SMF defaults 😁 Thanks!

@@ -4389,6 +4428,26 @@ struct translation_unit_node
}
};

// Definitions of out-of-line dtors for nodes with unique_ptr members of forward-declared types
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've decided to add the deferred dtor definitions here, at the point where (to the best of my knowledge) all node types are already defined.

@jarzec
Copy link
Contributor Author

jarzec commented May 31, 2024

@hsutter The PR with the discussed updates is ready. For some reason, when I created it GitHub runners had a bad time and some testes were cancelled/skipped. The changes are OK as you can see from the tests of the same commit in my own fork. You can also rerun the failed steps ones manually for the PR in the Actions section.

@jarzec
Copy link
Contributor Author

jarzec commented Jun 17, 2024

@hsutter I have rebased this branch on your current main to get all the CI tests to pass.

@hsutter
Copy link
Owner

hsutter commented Jun 22, 2024

Thanks!

@hsutter hsutter merged commit 5ac5df9 into hsutter:main Jun 22, 2024
28 checks passed
MarekKnapek pushed a commit to MarekKnapek/cppfront that referenced this pull request Jul 4, 2024
…tr members (hsutter#1088)

* Add OOL dtor defs to fix unique_ptr issues

* CI Add Clang 18 with C++23 in build  workflow
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants