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]

Re: [Bug c++/11179] New: valarray resize error


"mmckerns@caltech.edu" <gcc-bugzilla@gcc.gnu.org> writes:

[...]

| I believe there is an error in the valarray.resize source.

No, that is not an error: It is standard conformant behaviour.

| The behavior is different that resize for other C++ containers,
| such as vector.

valarray is not a container and is not designed to be a duplicate of
vector<>. 

[...]

| for valarray,
|   void resize(size_t _Newsize);                       sets all elements == 0
|   void resize(size_t _Newsize, const Type& _Val);     sets all elements == _Val

That is what the standard says:  See 26.3.2.7/9.

[...]

| SAMPLE OUTPUT:
| mmckerns>$ ./test
| val[0] = 0
| val[1] = 1
| val[2] = 2
| val[0] = 3
| val[1] = 3
| val[2] = 3
| val[3] = 3
| val[0] = 0
| val[1] = 0
| val[2] = 0

That is correct,

-- Gaby


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