| Hello, | | I found some unexpected behavior in valarray, couldn't find anything | previous referencing it, and I thought that I'd write before | (erroneously??) submitting a bug. | | Simple case: repeated application of operator== | | Silly example: | | std::valarray<int> v1(100,1); | std::valarray<int> v2(100,1); | std::valarray<bool> v3(100,true); | | std::valarray<bool> res; | | res = ((v1 == v2) == v3); | | | This returns a compile error. | | | test.cc: In function `int main()': | test.cc:16: error: no match for 'operator==' in 'std::operator== [with _Tp | = int](((const std::valarray<int>&)((const std::valarray<int>*)(& v1))), | ((const std::valarray<int>&)((const std::valarray<int>*)(& v2)))) == v1' | /usr/include/gcc/darwin/4.0/c++/bits/valarray_after.h:394: note: | candidates are: std::_Expr<std::_BinClos<std::__equal_to, std::_Expr, | std::_ValArray, _Dom, typename _Dom::value_type>, typename | std::__fun<std::__equal_to, typename _Dom1::value_type>::result_type> | std::operator==(const std::_Expr<_Dom1, typename _Dom1::value_type>&, | const std::valarray<typename _Dom::value_type>&) [with _Dom = | std::_BinClos<std::__equal_to, std::_ValArray, std::_ValArray, int, int>] | /usr/include/gcc/darwin/4.0/c++/bits/valarray_after.h:394: note: | std::_Expr<std::_BinClos<std::__equal_to, std::_Expr, std::_Constant, | _Dom, typename _Dom::value_type>, typename std::__fun<std::__equal_to, | typename _Dom1::value_type>::result_type> std::operator==(const | std::_Expr<_Dom1, typename _Dom1::value_type>&, const typename | _Dom::value_type&) [with _Dom = std::_BinClos<std::__equal_to, | std::_ValArray, std::_ValArray, int, int>] | | | This seems to happen regardless of the type of v3 BTW. Hmm, that must be a bug; please could you fill a PR in the GCC bugzilla database http://gcc.gnu.org/bugzilla/ and put me (gdr@gcc.gnu.org) in the CC:, and assign it to me? Thanks! -- Gaby
Gaby, I had a quick look and maybe it's just a trivial typo: the below seems right to me and certainly fixes the testcase without regressions... What do you think? Thanks, Paolo. ////////////// Index: include/bits/valarray_before.h =================================================================== --- include/bits/valarray_before.h (revision 114214) +++ include/bits/valarray_before.h (working copy) @@ -589,7 +589,7 @@ : _BinBase<_Oper, valarray<_Tp>, valarray<_Tp> > { typedef _BinBase<_Oper, valarray<_Tp>, valarray<_Tp> > _Base; - typedef _Tp value_type; + typedef typename _Base::value_type value_type; _BinClos(const valarray<_Tp>& __v, const valarray<_Tp>& __w) : _Base(__v, __w) {}
Confirmed on both GDR saying this is a bug and Paolo providing a patch to fix this.
Subject: Bug 27867 Author: paolo Date: Sun Jun 4 09:32:56 2006 New Revision: 114356 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=114356 Log: 2006-06-04 Paolo Carlini <pcarlini@suse.de> PR libstdc++/27867 * include/bits/valarray_before.h (struct _BinClos<_Oper, _ValArray, _ValArray, _Tp, _Tp>): Fix value_type typedef. * testsuite/26_numerics/valarray/27867.cc: New. Added: trunk/libstdc++-v3/testsuite/26_numerics/valarray/27867.cc Modified: trunk/libstdc++-v3/ChangeLog trunk/libstdc++-v3/include/bits/valarray_before.h
Fixed.