https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79349
Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Depends on| |23384 --- Comment #7 from Andrew Pinski <pinskia at gcc dot gnu.org> --- I am 99% sure this is actually due to the escape analysis is not fully flow sensitive. We think s can be modified by the call by foo but s does not escape until after the call to foo (via the exception basic block). So we don't optimize: ``` MEM[(struct _Alloc_hider *)&s]._M_p = &s.D.25271._M_local_buf; __builtin_memcpy (&s.D.25271._M_local_buf, "abc", 3); s._M_string_length = 3; MEM[(char_type &)&s + 19] = 0; foo (); <bb 3> [local count: 1073741824]: _24 = s._M_dataplus._M_p; if (&s.D.25271._M_local_buf == _24) ``` Which means this depends on PR 23384. Referenced Bugs: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=23384 [Bug 23384] escaped set should be flow sensitive