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++/57666] New: valarray<T>::operator= in c++11 mode does not adapt to size


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

            Bug ID: 57666
           Summary: valarray<T>::operator= in c++11 mode does not adapt to
                    size
           Product: gcc
           Version: 4.7.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: thunderliu at gmail dot com

Non-member operators for valarray<> returns instance of _Expr<> (lazy
evaluation?), instead of another valarray<>. This is non-conforming but
probably not a bug. But if the returned value is assigned to another
valarray<>, c++11 requires operator= to be size-adapting, but 4.7.2 does not do
that for _Expr<>.

For example:

#include <valarray>
extern "C" int printf(const char *, ...);

int main()
{
    typedef std::valarray<int> A;
    A a(3), b(3), d;
    d=a+b;
    printf("%d\n", d.size());   // 0, incorrect
    d=a;
    printf("%d\n", d.size());   // 3, correct
}

(Preprocessed source attached.)


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