Bug 27867 - compile error in repeated application of valarray<>::operator==
Summary: compile error in repeated application of valarray<>::operator==
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: libstdc++ (show other bugs)
Version: 4.1.0
: P3 normal
Target Milestone: 4.2.0
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-06-01 18:59 UTC by Mike Tegtmeyer
Modified: 2006-06-04 09:34 UTC (History)
4 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2006-06-02 02:21:08


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mike Tegtmeyer 2006-06-01 18:59:02 UTC
| 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
Comment 1 Paolo Carlini 2006-06-01 21:37:22 UTC
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) {}
Comment 2 Andrew Pinski 2006-06-02 02:21:08 UTC
Confirmed on both GDR saying this is a bug and Paolo providing a patch to fix this.
Comment 3 paolo@gcc.gnu.org 2006-06-04 09:33:04 UTC
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

Comment 4 Paolo Carlini 2006-06-04 09:34:02 UTC
Fixed.