https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87502
--- Comment #13 from M Welinder <terra at gnome dot org> --- > The reason why full destructor is inlined is that we do not know what > foo is doing and it may make the string bigger. "const" does not promise > that the callee does not modify the object. :-( > So I think all we can hope for is merging memcpy with the extra write of 0. That's not actually clear. It would be reasonable to assume that foo isn't likely to change the string and have the inlined destructor for a string that was initialized as a short string like here do something like if (stuff_got_changed) [[unlikely]] obj.noninlined_full_destructor(); That would still work if someone were to naughtily cast away the "const", but they would pay the price in the form of two jumps and the function call.