Skip to content

Conversation

egorzhdan
Copy link
Contributor

In libc++, std::optional inherits from several mixin base types. Some of those base types do not declare a deleted copy constructor for non-copyable value types, which works fine because clients are not supposed to use those base types directly from C++.

Swift, however, imports all of the transitive base types when importing a C++ type. As part of this, ClangImporter will attempt to instantiate e.g. std::__optional_copy_assign_base<NonCopyable>, and will fail with a hard error while doing so.

rdar://152718041

@egorzhdan
Copy link
Contributor Author

@swift-ci please smoke test

@egorzhdan egorzhdan force-pushed the egorzhdan/std-optional-noncopyable branch from 329c1c7 to cc27466 Compare September 9, 2025 14:39
@egorzhdan
Copy link
Contributor Author

@swift-ci please smoke test

…ptional<NonCopyable>`

In libc++, `std::optional` inherits from several mixin base types. Some of those base types do not declare a deleted copy constructor for non-copyable value types, which works fine because clients are not supposed to use those base types directly from C++.

Swift, however, imports all of the transitive base types when importing a C++ type. As part of this, ClangImporter will attempt to instantiate e.g. `std::__optional_copy_assign_base<NonCopyable>`, and will fail with a hard error while doing so.

rdar://152718041
@egorzhdan egorzhdan force-pushed the egorzhdan/std-optional-noncopyable branch from cc27466 to 124055a Compare September 10, 2025 11:34
@egorzhdan
Copy link
Contributor Author

@swift-ci please smoke test

@egorzhdan egorzhdan merged commit 30fc84c into swiftlang:main Sep 10, 2025
3 checks passed
@egorzhdan egorzhdan deleted the egorzhdan/std-optional-noncopyable branch September 10, 2025 17:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++ interop Feature: Interoperability with C++
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants