[Bug libstdc++/95833] Incorrect static_assert in std::reduce overload taking a binary functor
TonyELewis at hotmail dot com
gcc-bugzilla@gcc.gnu.org
Sat May 15 08:56:41 GMT 2021
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95833
Tony E Lewis <TonyELewis at hotmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |TonyELewis at hotmail dot com
--- Comment #1 from Tony E Lewis <TonyELewis at hotmail dot com> ---
I agree with the OP's report: I think this static_assert() is rejecting valid
calls and accepting invalid calls.
AFAIU from https://eel.is/c++draft/reduce, we don't require that *the range's
value type* is convertible to the type we're reducing to; we require that *the
binary operation always returns something* that's convertible to the type being
reduced to.
So I think these two lines in the numeric header:
static_assert(is_invocable_r_v<_Tp, _BinaryOperation&, _Tp&, _Tp&>);
static_assert(is_convertible_v<value_type, _Tp>);
...should instead be something like:
static_assert(is_invocable_r_v<_Tp, _BinaryOperation&, _Tp&, _Tp&>);
static_assert(is_invocable_r_v<_Tp, _BinaryOperation&, _Tp&, value_type&>);
static_assert(is_invocable_r_v<_Tp, _BinaryOperation&, value_type&, _Tp&>);
static_assert(is_invocable_r_v<_Tp, _BinaryOperation&, value_type&,
value_type&>);
(location :
https://github.com/gcc-mirror/gcc/blob/af42043e6618e69187b47f37dac870763c01e20f/libstdc%2B%2B-v3/include/std/numeric#L282
)
Thanks very much for all work on libstdc++.
More information about the Gcc-bugs
mailing list