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]

[Bug libstdc++/40691] New: bug in logical not operator for valarray used with slice


Use of operator! (logical not) from valarray with slice fails.  For example,

----------------------------------------------------------------------
#include <valarray>

void test01()
{
  const std::valarray<int> vi(12);
  std::valarray<bool> vb1(12);
  std::valarray<bool> vb2(3);
  std::slice s(0,3,4);

  vb1 = !vi;                         // ok
  vb2 = !(std::valarray<int>)vi[s];  // ok
  vb2 = !vi[s];                      // fails
}
----------------------------------------------------------------------

fails with:

elm3b187% /opt/gcc-nightly/trunk/bin/g++ -c valarray-bug.cc
In file included from
/opt/gcc-nightly/trunk-20090706/lib/gcc/powerpc64-linux/4.5.0/../../../../include/c++/4.5.0/valarray:562:0,
                 from valarray-bug.cc:1:
/opt/gcc-nightly/trunk-20090706/lib/gcc/powerpc64-linux/4.5.0/../../../../include/c++/4.5.0/bits/valarray_after.h:
In member function ?std::_Expr<std::_UnClos<std::__logical_not, std::_Expr,
_Clos>, bool> std::_Expr<_Clos, _Tp>::operator!() const [with _Clos =
std::_SClos<std::_ValArray, int>, _Tp = int]?:
valarray-bug.cc:12:14:   instantiated from here
/opt/gcc-nightly/trunk-20090706/lib/gcc/powerpc64-linux/4.5.0/../../../../include/c++/4.5.0/bits/valarray_after.h:318:61:
error: conversion from ?std::_Expr<std::_UnClos<std::__logical_not, std::_Expr,
std::_SClos<std::_ValArray, int> >, int>? to non-scalar type
?std::_Expr<std::_UnClos<std::__logical_not, std::_Expr,
std::_SClos<std::_ValArray, int> >, bool>? requested

That's std::_Expr<xxx<yyy,int>,int>
    to std::_expr<xxx<yyy,int>,bool>

I'm about to submit a proposed patch but would like a PR to keep track of this.


-- 
           Summary: bug in logical not operator for valarray used with slice
           Product: gcc
           Version: 4.5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: janis at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40691


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