The code shown below works nicely when compiled with -O2 or -O2 -g. However, it fails when compiled with -g, but only for std::complex<float>. For the other types it works well. Valgrind gives piles of uninitialized value errors. The same results are obtained when building on other Linux platforms. Also hen using bind1st the same problems arise. It works well with g++-3.4.3 though.
Cheers, Ger #include <iostream> #include <vector> #include <algorithm> #include <complex> template<typename TYPE> void testIt() { std::vector<TYPE> vecc(2, TYPE(2.)); std::vector<TYPE> result(2); // Test vector * scalar. std::transform (vecc.begin(), vecc.end(), result.begin(), bind2nd(std::multiplies<TYPE>(), TYPE(5.))); std::cout << result[0] << ' ' << result[1] << std::endl; } int main() { testIt<double>(); testIt<float>(); testIt<std::complex<float> >(); testIt<std::complex<double> >(); } -- Summary: std::transform is incorrect with std::multiples and bind2nd for complex<float> Product: gcc Version: 4.3.2 Status: UNCONFIRMED Severity: major Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: diepen at astron dot nl GCC build triplet: c++ -Wall -g tac.cc GCC host triplet: Linux dop131 2.6.27.19-3.2-default #1 SMP 2009-02-25 15:40:44 +0 GCC target triplet: same http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39678