[Bug libstdc++/112480] optional<T>::reset emits inefficient code when T is trivially-destructible
vanyacpp at gmail dot com
gcc-bugzilla@gcc.gnu.org
Mon Nov 13 10:34:31 GMT 2023
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112480
--- Comment #7 from Ivan Sorokin <vanyacpp at gmail dot com> ---
(In reply to Jonathan Wakely from comment #6)
> + // The following seems redundant but improves codegen, see PR 112480.
> + if constexpr (is_trivially_destructible_v<_Tp>)
> + this->_M_engaged = false;
> }
In theory non-trivial destructors that are optimizible to no-op can also
benefit from the same optimization.
I don't know how often non-trivial no-op destructors occur in practice. Perhaps
we can ignore such case.
More information about the Gcc-bugs
mailing list