https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87502
--- Comment #8 from Andrew Pinski <pinskia at gcc dot gnu.org> --- (In reply to Marc Glisse from comment #3) > (In reply to M Welinder from comment #2) > > The destruction still stinks: the full destructor is inlined instead of > > the small-string-only version (i.e., a no-op). Evidently gcc cannot > > see that the string remains a small-string. > > void foo (const std::string &s){ > const_cast<std::string&>(s)="some longer string so it needs proper > deletion"; > } I submitted PR 103827 for the similar case but only passed via a hidden reference instead.