Issue Details (XML | Word | Printable)

Key: STDCXX-512
Type: Bug Bug
Status: Open Open
Priority: Minor Minor
Assignee: Unassigned
Reporter: Martin Sebor
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
C++ Standard Library

std::valarray computed assignment operators don't compile with a user-defined class

Created: 08/Aug/07 09:17 PM   Updated: 13/Sep/09 12:01 AM
Component/s: 26. Numerics
Affects Version/s: 4.1.2, 4.1.3, 4.1.4
Fix Version/s: 4.2.2

Time Tracking:
Original Estimate: 4h
Original Estimate - 4h
Remaining Estimate: 4h
Remaining Estimate - 4h
Time Spent: Not Specified
Remaining Estimate - 4h

Issue Links:
Duplicate
 

Severity: Compiler Error


 Description  « Hide
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



 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Martin Sebor added a comment - 08/Aug/07 09:23 PM - edited
A test that demonstrates this problem was added to the test suite in r559650 .

See this thread for a discussion of the test failures.


Martin Sebor added a comment - 23/Aug/07 12:27 AM
Scheduled for 4.2.

Martin Sebor added a comment - 10/Oct/07 08:01 PM - edited
It's unusual to instantiate std::valarray on a user-defined type, so setting Priority to Minor. Since the template hasn't changed added other 4.1.x versions to the list of Affected Versions. It's too late to fix this now so deferred for 4.2.1 (provided a compatible fix is possible).

Martin Sebor added a comment - 23/Apr/08 12:31 AM
Disabled problematic tests again (see r650706) and deferred until 4.2.2.