https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112335
--- Comment #10 from Jonathan Wakely <redi at gcc dot gnu.org> --- Ah, now I understand what you've been saying about the postcondition. Yes, but the compiler doesn't know the postcondition, it's just words in the standard, so not visible to the optimization passes. It might be possible to add some optimization hints to the std::unique_ptr implementation to make the postcondition visible to the optimizer.