aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJonathan Wakely <jwakely@redhat.com>2024-07-22 20:24:19 +0100
committerJonathan Wakely <redi@gcc.gnu.org>2024-07-25 11:53:05 +0100
commiteb2c12561c10f78e03b4eb63685f937a107305f0 (patch)
tree6696cd9ff8f58b6100e9504a380a205a17b1aadf /gcc
parent3bf05516d9ffea2a39939b656f0e51052000653e (diff)
downloadgcc-eb2c12561c10f78e03b4eb63685f937a107305f0.zip
gcc-eb2c12561c10f78e03b4eb63685f937a107305f0.tar.gz
gcc-eb2c12561c10f78e03b4eb63685f937a107305f0.tar.bz2
libstdc++: Move std::optional assertions out of _M_get()
Currently we implement the precondition for accessing the contained value of a std::optional in the _M_get() accessor in the base class. This means that we always check the assertions even in internal functions that have an explicit check for a contained value being present, such as value() and value_or(U&&). Although those redundant assertions should get optimized out in most cases, they might hurt inliner heuristics and generally give the compiler more work to do. And they won't be optimized out at all for non-optimized builds. The current assertions also result in repeated invalid bug reports, such as PR 91281, PR 101659, PR 102712, and PR 107894. We can move the assertions from the internal accessors to the public member functions where the preconditions are specified. Reviewed-by: Ville Voutilainen <ville.voutilainen@gmail.com> libstdc++-v3/ChangeLog: * include/std/optional (_Optional_base_impl::_M_get()): Move assertions to ... (optional::operator->, optional::operator*): ... here.
Diffstat (limited to 'gcc')
0 files changed, 0 insertions, 0 deletions