[Bug c++/106151] Inconsistent optimization when defaulting aggregate vs non-aggregate
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106151 --- Comment #3 from Andrew Pinski --- (In reply to Barry Revzin from comment #2) > I guess that's like: > > C++11/14: neither is an aggregate (base class). > C++17: both are aggregates. > C++20: Bar is an aggregate, but Foo is not (user-declared constructor). > > But that really shouldn't affect the code-gen here? (right???) It changes because if the constructor is used or it is zero-initialized . And it just happens GCC is not able to optimize it back to what the zero-initialized can be done.
[Bug c++/106151] Inconsistent optimization when defaulting aggregate vs non-aggregate
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106151 --- Comment #2 from Barry Revzin --- I guess that's like: C++11/14: neither is an aggregate (base class). C++17: both are aggregates. C++20: Bar is an aggregate, but Foo is not (user-declared constructor). But that really shouldn't affect the code-gen here? (right???)
[Bug c++/106151] Inconsistent optimization when defaulting aggregate vs non-aggregate
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106151 Andrew Pinski changed: What|Removed |Added Component|middle-end |c++ --- Comment #1 from Andrew Pinski --- This is really interesting. -std=c++17 produces {} for both. -std=c++11/-std=c++14 produces the long code for both while -std=c++20 produces the wrose code for Foo::clear.