-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[IRGen] [Builtin] Update zeroInitializer to support addresses. #32591
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
Conversation
Adds support for addresses in `Builtin.zeroInitializer`. If an address is passed as the first (and only) argument, it will be zero'd out with a memset. This will "fix" the C++ default constructor for address types.
e69550f
to
6d86c17
Compare
I agree that this extension to |
Here's an example: struct Foo {
int x = 42;
Foo(Foo const&) { }
}; import Foo
public func test() {
let f = Foo()
}
Two things here. First, to directly address your question, (as seen above) we use
This is a good point. I should have put this in the summary but, I only intend for this to be a temporary solution. Right now we do the wrong thing. This is a smaller (and hopefully easier to commit) patch that makes it so other patches won't crash. I think we should always invoke the clang-generated constructor, that will fix this issue (and probably others that we don't know about). Once #30630 lands, I can implement that. |
Thinking more about it, maybe it is not that natural after all. For loadable types
Given that the temporary solution requires introducing extra complexity in |
Yeah, that's not a bad idea. Just don't emit an initializer. For all the cases that this constructor is "correct" it would still have the same behavior as initializing a stack object in C++. |
Given that C++ interop is an experimental feature that I hope nobody uses yet, what you're describing sounds like an acceptable temporary state until we get a final fix. |
OK. I'm going to close this, then. I'll make another patch to simply remove the |
Adds support for addresses in
Builtin.zeroInitializer
. If an address is passed as the first (and only) argument, it will be zero'd out with a memset.This will "fix" the C++ default constructor for address types.
The successor to #32530. Refs #32402.