This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/57666] New: valarray<T>::operator= in c++11 mode does not adapt to size
- From: "thunderliu at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 21 Jun 2013 08:55:07 +0000
- Subject: [Bug libstdc++/57666] New: valarray<T>::operator= in c++11 mode does not adapt to size
- Auto-submitted: auto-generated
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.)