https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103827
--- Comment #13 from Jan Hubicka <hubicka at ucw dot cz> --- > Yes, that object is defined const so can't be changed. But is this something > we > care about? Is it important to apply this optimization to noinline functions? There are few things where this helps. First inside the loop body and everything called from it we may assume that the value is unchanged. This lets us optimize: __attribute__ ((noinline)) void test(const struct foo a) { int b = a.a; a.bar(); if (a.a != b) printf ("optimize me away2"); } We can also use it to build jump functions. For example: #include <functional> //const std::function <void()> *escape; void test (const std::function <void()> f) { //escape=&f; f(); f(); } void bar(); int main2() { test (bar); return 0; } is IMO correct to be optimized to direct cals to bar() which we don't since we are worried about call to _M_manager modifing f. Also the original testcase is about optimizing destructors after function return...