Skip to content

std.optional.pointee not synthesized on newer MSVC STL releases #68068

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

Closed
compnerd opened this issue Aug 22, 2023 · 2 comments · Fixed by #69623
Closed

std.optional.pointee not synthesized on newer MSVC STL releases #68068

compnerd opened this issue Aug 22, 2023 · 2 comments · Fixed by #69623
Assignees
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. c++ interop Feature: Interoperability with C++

Comments

@compnerd
Copy link
Member

compnerd commented Aug 22, 2023

It seems that the std-optional test is failing as pointee is not synthesized. Taking a look at the std::optional implementation, it appears that we have the following structure:

struct S {
  constexpr void *& operator*() & noexcept;
  constexpr const void *& operator*() const & noexcept;
  constexpr void *&& operator*() && noexcept;
  constexpr const void *&& operator*() const && noexcept;
};

struct T: private S {
  using S::operator*;
};

I suspect that the use of using S::operator* is resulting in the decl not being visited as a CXXMethodDecl and subsequently we do not find the accessor.

From swift-ide-test -print-module -module-to-print=SR68068 -source-filename SR68068.swift -enable-experimental-cxx-interop:

struct S {
  init()
  var pointee: UnsafeRawPointer? { get nonmutating set }
  @available(*, unavailable, message: "use .pointee property")
  mutating func __operatorStar() -> UnsafeMutablePointer<UnsafeMutableRawPointer?>
  @available(*, unavailable, message: "use .pointee property")
  func __operatorStar() -> UnsafeMutablePointer<UnsafeRawPointer?>
  @available(*, unavailable, message: "use .pointee property")
  mutating func __operatorStar() -> UnsafeMutablePointer<UnsafeMutableRawPointer?>
  @available(*, unavailable, message: "use .pointee property")
  func __operatorStar() -> UnsafeMutablePointer<UnsafeRawPointer?>
}
struct T {
  init()
}

This results in the pointee member not being available.

@compnerd compnerd added bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. c++ interop Feature: Interoperability with C++ triage needed This issue needs more specific labels labels Aug 22, 2023
@compnerd
Copy link
Member Author

CC: @hyp @egorzhdan

@hyp
Copy link
Contributor

hyp commented Aug 22, 2023

@egorzhdan could you take this one?

compnerd added a commit that referenced this issue Aug 23, 2023
compnerd added a commit that referenced this issue Aug 24, 2023
compnerd added a commit that referenced this issue Aug 24, 2023
compnerd added a commit that referenced this issue Aug 25, 2023
compnerd added a commit that referenced this issue Aug 28, 2023
compnerd added a commit that referenced this issue Aug 28, 2023
compnerd added a commit that referenced this issue Aug 29, 2023
compnerd added a commit that referenced this issue Aug 30, 2023
compnerd added a commit that referenced this issue Aug 30, 2023
compnerd added a commit that referenced this issue Aug 31, 2023
compnerd added a commit that referenced this issue Aug 31, 2023
compnerd added a commit to compnerd/apple-swift that referenced this issue Sep 1, 2023
compnerd added a commit that referenced this issue Sep 2, 2023
@egorzhdan egorzhdan removed the triage needed This issue needs more specific labels label Nov 1, 2023
egorzhdan added a commit that referenced this issue Nov 2, 2023
…e classes

If a C++ type `Derived` inherits from `Base` privately, the public methods from `Base` should not be callable on an instance of `Derived`. However, C++ supports exposing such methods via a using declaration: `using MyPrivateBase::myPublicMethod;`.

MSVC started using this feature for `std::optional` which means Swift doesn't correctly import `var pointee: Pointee` for instantiations of `std::optional` on Windows. This prevents the automatic conformance to `CxxOptional` from being synthesized.

 rdar://114282353 / resolves #68068
egorzhdan added a commit that referenced this issue Nov 6, 2023
…e classes

If a C++ type `Derived` inherits from `Base` privately, the public methods from `Base` should not be callable on an instance of `Derived`. However, C++ supports exposing such methods via a using declaration: `using MyPrivateBase::myPublicMethod;`.

MSVC started using this feature for `std::optional` which means Swift doesn't correctly import `var pointee: Pointee` for instantiations of `std::optional` on Windows. This prevents the automatic conformance to `CxxOptional` from being synthesized.

 rdar://114282353 / resolves #68068
egorzhdan added a commit that referenced this issue Nov 8, 2023
…e classes

If a C++ type `Derived` inherits from `Base` privately, the public methods from `Base` should not be callable on an instance of `Derived`. However, C++ supports exposing such methods via a using declaration: `using MyPrivateBase::myPublicMethod;`.

MSVC started using this feature for `std::optional` which means Swift doesn't correctly import `var pointee: Pointee` for instantiations of `std::optional` on Windows. This prevents the automatic conformance to `CxxOptional` from being synthesized.

 rdar://114282353 / resolves #68068
egorzhdan added a commit that referenced this issue Nov 9, 2023
…e classes

If a C++ type `Derived` inherits from `Base` privately, the public methods from `Base` should not be callable on an instance of `Derived`. However, C++ supports exposing such methods via a using declaration: `using MyPrivateBase::myPublicMethod;`.

MSVC started using this feature for `std::optional` which means Swift doesn't correctly import `var pointee: Pointee` for instantiations of `std::optional` on Windows. This prevents the automatic conformance to `CxxOptional` from being synthesized.

 rdar://114282353 / resolves #68068
egorzhdan added a commit that referenced this issue Nov 10, 2023
…e classes

If a C++ type `Derived` inherits from `Base` privately, the public methods from `Base` should not be callable on an instance of `Derived`. However, C++ supports exposing such methods via a using declaration: `using MyPrivateBase::myPublicMethod;`.

MSVC started using this feature for `std::optional` which means Swift doesn't correctly import `var pointee: Pointee` for instantiations of `std::optional` on Windows. This prevents the automatic conformance to `CxxOptional` from being synthesized.

 rdar://114282353 / resolves #68068
egorzhdan added a commit that referenced this issue Nov 13, 2023
…e classes

If a C++ type `Derived` inherits from `Base` privately, the public methods from `Base` should not be callable on an instance of `Derived`. However, C++ supports exposing such methods via a using declaration: `using MyPrivateBase::myPublicMethod;`.

MSVC started using this feature for `std::optional` which means Swift doesn't correctly import `var pointee: Pointee` for instantiations of `std::optional` on Windows. This prevents the automatic conformance to `CxxOptional` from being synthesized.

 rdar://114282353 / resolves #68068
egorzhdan added a commit that referenced this issue Nov 13, 2023
…e classes

If a C++ type `Derived` inherits from `Base` privately, the public methods from `Base` should not be callable on an instance of `Derived`. However, C++ supports exposing such methods via a using declaration: `using MyPrivateBase::myPublicMethod;`.

MSVC started using this feature for `std::optional` which means Swift doesn't correctly import `var pointee: Pointee` for instantiations of `std::optional` on Windows. This prevents the automatic conformance to `CxxOptional` from being synthesized.

 rdar://114282353 / resolves #68068
egorzhdan added a commit that referenced this issue Nov 13, 2023
…e classes

If a C++ type `Derived` inherits from `Base` privately, the public methods from `Base` should not be callable on an instance of `Derived`. However, C++ supports exposing such methods via a using declaration: `using MyPrivateBase::myPublicMethod;`.

MSVC started using this feature for `std::optional` which means Swift doesn't correctly import `var pointee: Pointee` for instantiations of `std::optional` on Windows. This prevents the automatic conformance to `CxxOptional` from being synthesized.

 rdar://114282353 / resolves #68068
egorzhdan added a commit that referenced this issue Nov 13, 2023
…e classes

If a C++ type `Derived` inherits from `Base` privately, the public methods from `Base` should not be callable on an instance of `Derived`. However, C++ supports exposing such methods via a using declaration: `using MyPrivateBase::myPublicMethod;`.

MSVC started using this feature for `std::optional` which means Swift doesn't correctly import `var pointee: Pointee` for instantiations of `std::optional` on Windows. This prevents the automatic conformance to `CxxOptional` from being synthesized.

 rdar://114282353 / resolves #68068
egorzhdan added a commit that referenced this issue Nov 13, 2023
…e classes

If a C++ type `Derived` inherits from `Base` privately, the public methods from `Base` should not be callable on an instance of `Derived`. However, C++ supports exposing such methods via a using declaration: `using MyPrivateBase::myPublicMethod;`.

MSVC started using this feature for `std::optional` which means Swift doesn't correctly import `var pointee: Pointee` for instantiations of `std::optional` on Windows. This prevents the automatic conformance to `CxxOptional` from being synthesized.

 rdar://114282353 / resolves #68068
egorzhdan added a commit that referenced this issue Nov 13, 2023
…e classes

If a C++ type `Derived` inherits from `Base` privately, the public methods from `Base` should not be callable on an instance of `Derived`. However, C++ supports exposing such methods via a using declaration: `using MyPrivateBase::myPublicMethod;`.

MSVC started using this feature for `std::optional` which means Swift doesn't correctly import `var pointee: Pointee` for instantiations of `std::optional` on Windows. This prevents the automatic conformance to `CxxOptional` from being synthesized.

 rdar://114282353 / resolves #68068
egorzhdan added a commit that referenced this issue Nov 13, 2023
…e classes

If a C++ type `Derived` inherits from `Base` privately, the public methods from `Base` should not be callable on an instance of `Derived`. However, C++ supports exposing such methods via a using declaration: `using MyPrivateBase::myPublicMethod;`.

MSVC started using this feature for `std::optional` which means Swift doesn't correctly import `var pointee: Pointee` for instantiations of `std::optional` on Windows. This prevents the automatic conformance to `CxxOptional` from being synthesized.

 rdar://114282353 / resolves #68068
egorzhdan added a commit that referenced this issue Nov 14, 2023
…e classes

If a C++ type `Derived` inherits from `Base` privately, the public methods from `Base` should not be callable on an instance of `Derived`. However, C++ supports exposing such methods via a using declaration: `using MyPrivateBase::myPublicMethod;`.

MSVC started using this feature for `std::optional` which means Swift doesn't correctly import `var pointee: Pointee` for instantiations of `std::optional` on Windows. This prevents the automatic conformance to `CxxOptional` from being synthesized.

 rdar://114282353 / resolves #68068
hjyamauchi added a commit to hjyamauchi/swift that referenced this issue Nov 13, 2024
…e classes

If a C++ type `Derived` inherits from `Base` privately, the public methods from `Base` should not be callable on an instance of `Derived`. However, C++ supports exposing such methods via a using declaration: `using MyPrivateBase::myPublicMethod;`.

MSVC started using this feature for `std::optional` which means Swift doesn't correctly import `var pointee: Pointee` for instantiations of `std::optional` on Windows. This prevents the automatic conformance to `CxxOptional` from being synthesized.

rdar://114282353 / resolves swiftlang#68068

Cherrypick commit efc008a
Cherrypick PR swiftlang#69623
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. c++ interop Feature: Interoperability with C++
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants