Skip to content

[cxx-interop][regression] methods returning vector are unsafe unless vector instantiated prior in a type alias. #65446

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

Open
hyp opened this issue Apr 26, 2023 · 2 comments
Assignees
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. c++ interop Feature: Interoperability with C++ swift 5.9

Comments

@hyp
Copy link
Contributor

hyp commented Apr 26, 2023

After #64897 our safe/unsafe method detection logic has regressed .

For example, let's say we're returning a vector:

class SimplePOD {
public:
    int x;
};

class VecOwner {
public:
    std::vector<SimplePOD> getPODItems() const;
};

The module interface will mark the method as unsafe:

struct VecOwner {
  init()
  func __getPODItemsUnsafe() -> std.__1.vector<SimplePOD, allocator<SimplePOD>>
  @available(swift, obsoleted: 5, renamed: "__getPODItemsUnsafe()")
  func getPODItems() -> std.__1.vector<SimplePOD, allocator<SimplePOD>>
}
@hyp hyp 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 swift 5.9 labels Apr 26, 2023
@hyp
Copy link
Contributor Author

hyp commented Apr 26, 2023

workaround, instantiate the vector template in a type alias.

@hyp
Copy link
Contributor Author

hyp commented Apr 26, 2023

we should revert #64897 for now.

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++ swift 5.9
Projects
None yet
Development

No branches or pull requests

3 participants