https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117279
Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Severity|normal |enhancement Status|UNCONFIRMED |NEW Last reconfirmed| |2024-10-24 Ever confirmed|0 |1 --- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> --- We don't optimize away the load of `p._M_string_length` after the printf. ``` __builtin_memcpy (&p.D.27115._M_local_buf, "Hello world", 11); p._M_string_length = 11; MEM[(char_type &)&p + 27] = 0; _22 = (long unsigned int) index_8(D); _20 = &p.D.27115._M_local_buf + _22; _3 = *_20; _4 = (int) _3; __builtin_printf ("%c\n", _4); <bb 4> [local count: 472360499]: _21 = p._M_string_length; ``` We must think p escapes somehow. I have not looked into why though.