-
Notifications
You must be signed in to change notification settings - Fork 1.6k
<optional>: Don't zero storage in default constructor #878
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
Providing a minor runtime and codesize benefit.
|
Given that the compiler is moving to initialize all the things does this even have an effect? |
|
Makes sense for me given that it is invalid to access an unassigned optional anyway. |
Yes, as verified by inspection of the assembly generated for: std::optional<std::array<int, 1024>> potato() {
return {};
}Before: with just the change to with the |
Providing a minor runtime and codesize benefit.
Thanks to Ville Voutilainen for the suggestion.