[Bug tree-optimization/93540] Attributes pure and const not working with aggregate return types, even trivial ones
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93540 Andrew Pinski changed: What|Removed |Added Resolution|--- |DUPLICATE Status|UNCONFIRMED |RESOLVED --- Comment #3 from Andrew Pinski --- Dup of bug 59739. *** This bug has been marked as a duplicate of bug 59739 ***
[Bug tree-optimization/93540] Attributes pure and const not working with aggregate return types, even trivial ones
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93540 Trass3r changed: What|Removed |Added CC||trass3r at gmail dot com --- Comment #2 from Trass3r --- I also ran into this when trying to optimize trivial but expensive getter functions, e.g. returning shared_ptr. struct Foo { int operator+(const Foo& f); int a; }; [[gnu::const]] Foo foo(); // int instead of Foo works auto testfunction() { return foo() + foo(); // results in 2 calls }
[Bug tree-optimization/93540] Attributes pure and const not working with aggregate return types, even trivial ones
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93540 Andrew Pinski changed: What|Removed |Added Keywords||missed-optimization Component|c |tree-optimization Severity|normal |enhancement --- Comment #1 from Andrew Pinski --- Yes this is expected. GCC only currently handles non-aggregate pure/const functions (vector and complex types work).