std::valarray computed assignment operators don't compile with a user-defined class -----------------------------------------------------------------------------------
Key: STDCXX-512 URL: https://issues.apache.org/jira/browse/STDCXX-512 Project: C++ Standard Library Issue Type: Bug Components: 26. Numerics Affects Versions: 4.1.3 Reporter: Martin Sebor The program below fails to compile because the valarray computed assignment operators make use of operator@ (T, T) instead of the corresponding computed assignment operators defined by T (i.e., T::operator@(T)). $ cat u.cpp && make u #include <valarray> struct Value { Value& operator*= (const Value&) { return *this; } Value& operator/= (const Value&) { return *this; } Value& operator+= (const Value&) { return *this; } Value& operator-= (const Value&) { return *this; } Value& operator%= (const Value&) { return *this; } Value& operator^= (const Value&) { return *this; } Value& operator&= (const Value&) { return *this; } Value& operator|= (const Value&) { return *this; } Value& operator<<= (const Value&) { return *this; } Value& operator>>= (const Value&) { return *this; } }; int main () { std::valarray<Value> val; val *= val; val /= val; val += val; val -= val; val %= val; val ^= val; val &= val; val |= val; val <<= val; val >>= val; } gcc -c -I/amd/devco/sebor/stdcxx-4.1.3/include/ansi -D_RWSTDDEBUG -pthread -D_RWSTD_USE_CONFIG -I/build/sebor/stdcxx-4.1.3-gcc-3.4.3_6-15D/include -I/amd/devco/sebor/stdcxx-4.1.3/include -I/amd/devco/sebor/stdcxx-4.1.3/examples/include -pedantic -nostdinc++ -g -m64 -Wall -W -Wcast-qual -Winline -Wshadow -Wwrite-strings -Wno-long-long -Wcast-align u.cpp /amd/devco/sebor/stdcxx-4.1.3/include/functional: In member function `typename std::binary_function<_TypeT, _TypeT, _TypeT>::result_type std::multiplies<_TypeT>::operator()(const typename std::binary_function<_TypeT, _TypeT, _TypeT>::first_argument_type&, const typename std::binary_function<_TypeT, _TypeT, _TypeT>::second_argument_type&) const [with _TypeT = Value]': /amd/devco/sebor/stdcxx-4.1.3/include/algorithm:353: instantiated from `_OutputIter std::transform(_InputIter1, _InputIter1, _InputIter2, _OutputIter, _BinaryOperation) [with _InputIter1 = Value*, _InputIter2 = const Value*, _OutputIter = Value*, _BinaryOperation = std::multiplies<Value>]' /amd/devco/sebor/stdcxx-4.1.3/include/valarray:363: instantiated from `std::valarray<_TypeT>& std::valarray<_TypeT>::operator*=(const std::valarray<_TypeT>&) [with _TypeT = Value]' u.cpp:20: instantiated from here /amd/devco/sebor/stdcxx-4.1.3/include/functional:83: error: no match for 'operator*' in '__x * __y' /amd/devco/sebor/stdcxx-4.1.3/include/functional: In member function `typename std::binary_function<_TypeT, _TypeT, _TypeT>::result_type std::divides<_TypeT>::operator()(const typename std::binary_function<_TypeT, _TypeT, _TypeT>::first_argument_type&, const typename std::binary_function<_TypeT, _TypeT, _TypeT>::second_argument_type&) const [with _TypeT = Value]': /amd/devco/sebor/stdcxx-4.1.3/include/algorithm:353: instantiated from `_OutputIter std::transform(_InputIter1, _InputIter1, _InputIter2, _OutputIter, _BinaryOperation) [with _InputIter1 = Value*, _InputIter2 = const Value*, _OutputIter = Value*, _BinaryOperation = std::divides<Value>]' /amd/devco/sebor/stdcxx-4.1.3/include/valarray:376: instantiated from `std::valarray<_TypeT>& std::valarray<_TypeT>::operator/=(const std::valarray<_TypeT>&) [with _TypeT = Value]' u.cpp:21: instantiated from here /amd/devco/sebor/stdcxx-4.1.3/include/functional:96: error: no match for 'operator/' in '__x / __y' /amd/devco/sebor/stdcxx-4.1.3/include/functional: In member function `typename std::binary_function<_TypeT, _TypeT, _TypeT>::result_type std::plus<_TypeT>::operator()(const typename std::binary_function<_TypeT, _TypeT, _TypeT>::first_argument_type&, const typename std::binary_function<_TypeT, _TypeT, _TypeT>::second_argument_type&) const [with _TypeT = Value]': /amd/devco/sebor/stdcxx-4.1.3/include/algorithm:353: instantiated from `_OutputIter std::transform(_InputIter1, _InputIter1, _InputIter2, _OutputIter, _BinaryOperation) [with _InputIter1 = Value*, _InputIter2 = const Value*, _OutputIter = Value*, _BinaryOperation = std::plus<Value>]' /amd/devco/sebor/stdcxx-4.1.3/include/valarray:389: instantiated from `std::valarray<_TypeT>& std::valarray<_TypeT>::operator+=(const std::valarray<_TypeT>&) [with _TypeT = Value]' u.cpp:22: instantiated from here /amd/devco/sebor/stdcxx-4.1.3/include/functional:57: error: no match for 'operator+' in '__x + __y' /amd/devco/sebor/stdcxx-4.1.3/include/functional: In member function `typename std::binary_function<_TypeT, _TypeT, _TypeT>::result_type std::minus<_TypeT>::operator()(const typename std::binary_function<_TypeT, _TypeT, _TypeT>::first_argument_type&, const typename std::binary_function<_TypeT, _TypeT, _TypeT>::second_argument_type&) const [with _TypeT = Value]': /amd/devco/sebor/stdcxx-4.1.3/include/algorithm:353: instantiated from `_OutputIter std::transform(_InputIter1, _InputIter1, _InputIter2, _OutputIter, _BinaryOperation) [with _InputIter1 = Value*, _InputIter2 = const Value*, _OutputIter = Value*, _BinaryOperation = std::minus<Value>]' /amd/devco/sebor/stdcxx-4.1.3/include/valarray:402: instantiated from `std::valarray<_TypeT>& std::valarray<_TypeT>::operator-=(const std::valarray<_TypeT>&) [with _TypeT = Value]' u.cpp:23: instantiated from here /amd/devco/sebor/stdcxx-4.1.3/include/functional:70: error: no match for 'operator-' in '__x - __y' /amd/devco/sebor/stdcxx-4.1.3/include/functional: In member function `typename std::binary_function<_TypeT, _TypeT, _TypeT>::result_type std::modulus<_TypeT>::operator()(const typename std::binary_function<_TypeT, _TypeT, _TypeT>::first_argument_type&, const typename std::binary_function<_TypeT, _TypeT, _TypeT>::second_argument_type&) const [with _TypeT = Value]': /amd/devco/sebor/stdcxx-4.1.3/include/algorithm:353: instantiated from `_OutputIter std::transform(_InputIter1, _InputIter1, _InputIter2, _OutputIter, _BinaryOperation) [with _InputIter1 = Value*, _InputIter2 = const Value*, _OutputIter = Value*, _BinaryOperation = std::modulus<Value>]' /amd/devco/sebor/stdcxx-4.1.3/include/valarray:415: instantiated from `std::valarray<_TypeT>& std::valarray<_TypeT>::operator%=(const std::valarray<_TypeT>&) [with _TypeT = Value]' u.cpp:24: instantiated from here /amd/devco/sebor/stdcxx-4.1.3/include/functional:109: error: no match for 'operator%' in '__x % __y' /amd/devco/sebor/stdcxx-4.1.3/include/functional: In member function `typename std::binary_function<_TypeT, _TypeT, _TypeT>::result_type __rw::exclusive_or<_TypeT>::operator()(const typename std::binary_function<_TypeT, _TypeT, _TypeT>::first_argument_type&, const typename std::binary_function<_TypeT, _TypeT, _TypeT>::second_argument_type&) const [with _TypeT = Value]': /amd/devco/sebor/stdcxx-4.1.3/include/algorithm:353: instantiated from `_OutputIter std::transform(_InputIter1, _InputIter1, _InputIter2, _OutputIter, _BinaryOperation) [with _InputIter1 = Value*, _InputIter2 = const Value*, _OutputIter = Value*, _BinaryOperation = __rw::exclusive_or<Value>]' /amd/devco/sebor/stdcxx-4.1.3/include/valarray:428: instantiated from `std::valarray<_TypeT>& std::valarray<_TypeT>::operator^=(const std::valarray<_TypeT>&) [with _TypeT = Value]' u.cpp:25: instantiated from here /amd/devco/sebor/stdcxx-4.1.3/include/functional:732: error: no match for 'operator^' in '__x ^ __y' /amd/devco/sebor/stdcxx-4.1.3/include/functional: In member function `typename std::binary_function<_TypeT, _TypeT, _TypeT>::result_type __rw::bitwise_and<_TypeT>::operator()(const typename std::binary_function<_TypeT, _TypeT, _TypeT>::first_argument_type&, const typename std::binary_function<_TypeT, _TypeT, _TypeT>::second_argument_type&) const [with _TypeT = Value]': /amd/devco/sebor/stdcxx-4.1.3/include/algorithm:353: instantiated from `_OutputIter std::transform(_InputIter1, _InputIter1, _InputIter2, _OutputIter, _BinaryOperation) [with _InputIter1 = Value*, _InputIter2 = const Value*, _OutputIter = Value*, _BinaryOperation = __rw::bitwise_and<Value>]' /amd/devco/sebor/stdcxx-4.1.3/include/valarray:441: instantiated from `std::valarray<_TypeT>& std::valarray<_TypeT>::operator&=(const std::valarray<_TypeT>&) [with _TypeT = Value]' u.cpp:26: instantiated from here /amd/devco/sebor/stdcxx-4.1.3/include/functional:719: error: no match for 'operator&' in '__x & __y' /amd/devco/sebor/stdcxx-4.1.3/include/functional: In member function `typename std::binary_function<_TypeT, _TypeT, _TypeT>::result_type __rw::bitwise_or<_TypeT>::operator()(const typename std::binary_function<_TypeT, _TypeT, _TypeT>::first_argument_type&, const typename std::binary_function<_TypeT, _TypeT, _TypeT>::second_argument_type&) const [with _TypeT = Value]': /amd/devco/sebor/stdcxx-4.1.3/include/algorithm:353: instantiated from `_OutputIter std::transform(_InputIter1, _InputIter1, _InputIter2, _OutputIter, _BinaryOperation) [with _InputIter1 = Value*, _InputIter2 = const Value*, _OutputIter = Value*, _BinaryOperation = __rw::bitwise_or<Value>]' /amd/devco/sebor/stdcxx-4.1.3/include/valarray:454: instantiated from `std::valarray<_TypeT>& std::valarray<_TypeT>::operator|=(const std::valarray<_TypeT>&) [with _TypeT = Value]' u.cpp:27: instantiated from here /amd/devco/sebor/stdcxx-4.1.3/include/functional:706: error: no match for 'operator|' in '__x | __y' /amd/devco/sebor/stdcxx-4.1.3/include/functional: In member function `typename std::binary_function<_TypeT, _TypeT, _TypeT>::result_type __rw::shift_left<_TypeT>::operator()(const typename std::binary_function<_TypeT, _TypeT, _TypeT>::first_argument_type&, const typename std::binary_function<_TypeT, _TypeT, _TypeT>::second_argument_type&) const [with _TypeT = Value]': /amd/devco/sebor/stdcxx-4.1.3/include/algorithm:353: instantiated from `_OutputIter std::transform(_InputIter1, _InputIter1, _InputIter2, _OutputIter, _BinaryOperation) [with _InputIter1 = Value*, _InputIter2 = const Value*, _OutputIter = Value*, _BinaryOperation = __rw::shift_left<Value>]' /amd/devco/sebor/stdcxx-4.1.3/include/valarray:467: instantiated from `std::valarray<_TypeT>& std::valarray<_TypeT>::operator<<=(const std::valarray<_TypeT>&) [with _TypeT = Value]' u.cpp:28: instantiated from here /amd/devco/sebor/stdcxx-4.1.3/include/functional:745: error: no match for 'operator<<' in '__x << __y' /amd/devco/sebor/stdcxx-4.1.3/include/functional: In member function `typename std::binary_function<_TypeT, _TypeT, _TypeT>::result_type __rw::shift_right<_TypeT>::operator()(const typename std::binary_function<_TypeT, _TypeT, _TypeT>::first_argument_type&, const typename std::binary_function<_TypeT, _TypeT, _TypeT>::second_argument_type&) const [with _TypeT = Value]': /amd/devco/sebor/stdcxx-4.1.3/include/algorithm:353: instantiated from `_OutputIter std::transform(_InputIter1, _InputIter1, _InputIter2, _OutputIter, _BinaryOperation) [with _InputIter1 = Value*, _InputIter2 = const Value*, _OutputIter = Value*, _BinaryOperation = __rw::shift_right<Value>]' /amd/devco/sebor/stdcxx-4.1.3/include/valarray:480: instantiated from `std::valarray<_TypeT>& std::valarray<_TypeT>::operator>>=(const std::valarray<_TypeT>&) [with _TypeT = Value]' u.cpp:29: instantiated from here /amd/devco/sebor/stdcxx-4.1.3/include/functional:758: error: no match for 'operator>>' in '__x >> __y' make: *** [u.o] Error 1 -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.