This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: [Bug c++/11179] New: valarray resize error
- From: Gabriel Dos Reis <gdr at integrable-solutions dot net>
- To: gcc-bugzilla at gcc dot gnu dot org
- Cc: gcc-bugs at gcc dot gnu dot org
- Date: 14 Jun 2003 01:39:03 +0200
- Subject: Re: [Bug c++/11179] New: valarray resize error
- Organization: Integrable Solutions
- References: <20030612223137.11179.mmckerns@caltech.edu>
"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