This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
libstdc++/9234: [3.3/3.4 regression] unary minus for valarrays broken
- From: reichelt at igpm dot rwth-aachen dot de
- To: gcc-gnats at gcc dot gnu dot org
- Cc: gdr at integrable-solutions dot net
- Date: 8 Jan 2003 22:47:22 -0000
- Subject: libstdc++/9234: [3.3/3.4 regression] unary minus for valarrays broken
- Reply-to: reichelt at igpm dot rwth-aachen dot de
>Number: 9234
>Category: libstdc++
>Synopsis: [3.3/3.4 regression] unary minus for valarrays broken
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: wrong-code
>Submitter-Id: net
>Arrival-Date: Wed Jan 08 14:56:02 PST 2003
>Closed-Date:
>Last-Modified:
>Originator: Volker Reichelt
>Release: 3.3-20021230, 3.4-20021230
>Organization:
>Environment:
i686-pc-linux-gnu
>Description:
The following program should return -1, but returns 1 instead
(just compile with "g++ -c"):
-----------------------snip here------------------
#include<valarray>
int main ()
{
std::valarray<int> u(1);
u[0]=1;
return (-u)[0];
}
-----------------------snip here------------------
I think that Gaby's patch
http://gcc.gnu.org/ml/gcc-patches/2002-08/msg00197.html
caused the regression, since the patch below fixes the
problem for me. (I didn't do a bootstrap or regression
tests, though.)
>How-To-Repeat:
g++ -c
>Fix:
===========================================================
--- gcc-old/libstdc++-v3/include/bits/valarray_meta.h Sat Jan 4 01:37:31 2003
+++ gcc-new/libstdc++-v3/include/bits/valarray_meta.h Wed Jan 8 23:26:44 2003
@@ -457,7 +457,7 @@ namespace std
_UnBase(const _Arg& __e) : _M_expr(__e) {}
value_type operator[](size_t __i) const
- { return _M_expr[__i]; }
+ { return _Oper() (_M_expr[__i]); }
size_t size() const { return _M_expr.size(); }
============================================================
>Release-Note:
>Audit-Trail:
>Unformatted: