This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

libstdc++/9234: [3.3/3.4 regression] unary minus for valarrays broken


>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:


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]