Skip to content

[Code Health] Improve eventual C++20 support. #67683

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

Merged
merged 3 commits into from
Aug 3, 2023

Conversation

allevato
Copy link
Member

@allevato allevato commented Aug 2, 2023

This is a small set of patches we've been floating for a while, to allow Swift to be built in a C++20 configuration. This PR contains the following changes:

  • Add explicit ctors for types that default or delete their ctors, when aggregate initialization is being used. (In C++20, the type is no longer an aggregate if its ctors are defaulted or deleted).
  • Ensure that any types used as elements of std::vector are complete and not just forward-declared.
  • (Not strictly a C++20 change) Ensure that LinkEntity is zero-initialized to avoid use-of-uninitialized-value problems.

All should remain compatible with earlier C++ versions as well.

…tors.

In C++20, types that declare or delete their default/copy/move constructors are no longer aggregates, so the aggregate uses of these types will not compile under C++20. Adding them fixes this, without affecting older language modes.
These were never allowed, but with C++20 making more `vector` functions
`constexpr`, they would start causing build failures in that language
mode.
@allevato
Copy link
Member Author

allevato commented Aug 2, 2023

@swift-ci please test

1 similar comment
@allevato
Copy link
Member Author

allevato commented Aug 3, 2023

@swift-ci please test

@compnerd
Copy link
Member

compnerd commented Aug 3, 2023

@swift-ci please test Windows platform

@allevato allevato merged commit b59f5c7 into swiftlang:main Aug 3, 2023
@allevato allevato deleted the c++20-tweaks branch August 3, 2023 17:24
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