[Bug libstdc++/78490] New: [c++17] libstdc++ has undefined behavior in operator= of propagate_const
felix.morgner at gmail dot com
gcc-bugzilla@gcc.gnu.org
Wed Nov 23 09:29:00 GMT 2016
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78490
Bug ID: 78490
Summary: [c++17] libstdc++ has undefined behavior in operator=
of propagate_const
Product: gcc
Version: 6.2.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libstdc++
Assignee: unassigned at gcc dot gnu.org
Reporter: felix.morgner at gmail dot com
Target Milestone: ---
The implementation of propagate_const libstdc++ 6.0.22 has undefined behavior
in operator=
The implementation reads as follows:
template <typename _Up, typename =
typename enable_if<is_convertible<_Up&&, _Tp>::value>::type>
constexpr propagate_const& operator=(propagate_const<_Up>&& __pu)
{
_M_t = std::move(get_underlying(__pu));
}
template <typename _Up, typename =
typename enable_if<__and_<is_convertible<_Up&&, _Tp>,
__not_<__is_propagate_const<
typename decay<_Up>::type>>
>::value>::type>
constexpr propagate_const& operator=(_Up&& __u)
{
_M_t = std::forward<_Up>(__u);
}
Both overloads of operator= are missing an appropriate return statement,
causing undefined behavior.
More information about the Gcc-bugs
mailing list