Describe the bug
in std::reduce(), binary_op(*first,*first) must be convertible to T. This isn't the case in the below code yet it compiles.
Command-line test case
C:\Temp>type repro.cpp
#include <iostream>
int main() {
std::random_device e;
std::uniform_int_distribution<> dist(1, 10);
const int n = 10;
std::vector<int> v(n);
std::generate(v.begin(), v.end(), [&]() {return dist(e); });
const auto result = std::reduce(v.begin(), v.end(), std::make_pair(0, 0),
[](std::pair<int,int> sum,int n) {
n % 2 == 1?sum.first += n:sum.second += n;
return sum;
});
}
C:\Temp>cl /EHsc /W4 /WX .\repro.cpp
Microsoft (R) C/C++ Optimizing Compiler Version 19.26.28806 for x86
Copyright (C) Microsoft Corporation. All rights reserved.
repro.cpp
Microsoft (R) Incremental Linker Version 14.26.28806.0
Copyright (C) Microsoft Corporation. All rights reserved.
/out:repo.exe
repro.obj
Expected behavior
It shouldn't compile
STL version
Microsoft Visual Studio Community 2019 Version 16.6.1
Additional context
gcc and clang reject the above code
Describe the bug
in std::reduce(), binary_op(*first,*first) must be convertible to T. This isn't the case in the below code yet it compiles.
Command-line test case
Expected behavior
It shouldn't compile
STL version
Microsoft Visual Studio Community 2019 Version 16.6.1Additional context
gcc and clang reject the above code