https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95833
Bug ID: 95833 Summary: Incorrect static_assert in std::reduce overload taking a binary functor Product: gcc Version: 10.0 URL: https://stackoverflow.com/q/62499765 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: eugns.p at gmail dot com Target Milestone: --- Created attachment 48773 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=48773&action=edit Preprocessed code for minimal example The std::reduce overload that takes a binary functor template<typename _InputIterator, typename _Tp, typename _BinaryOperation> _Tp reduce(_InputIterator, _InputIterator, _Tp, _BinaryOperation); (defined here: https://github.com/gcc-mirror/gcc/blob/releases/gcc-10/libstdc%2B%2B-v3/include/std/numeric#L236) contains an incorrect static assertion: static_assert(is_convertible_v<value_type, _Tp>); There is no such requirement in the standard. This static assert causes a compilation failure of the following minimal example: #include <iostream> #include <array> #include <numeric> #include <cstring> struct StringLength { auto operator()(const char* l, std::size_t r) const { return std::strlen(l) + r; } auto operator()(std::size_t l, const char* r) const { return l + std::strlen(r); } auto operator()(const char* l, const char* r) const { return std::strlen(l) + std::strlen(r); } auto operator()(std::size_t l, std::size_t r) const { return l + r; } }; int main() { std::array<const char*, 3> arr{"A", "B", "C"}; std::cout << std::reduce(arr.begin(), arr.end(), std::size_t{}, StringLength{}); } https://godbolt.org/z/Av3iY9