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++/11179] valarray resize error


PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

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


giovannibajo@libero.it changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
          Component|c++                         |libstdc++
         Resolution|                            |INVALID


------- Additional Comments From giovannibajo@libero.it  2003-06-13 02:07 -------
And what would you expect exactly? The semantic of valarray::resize(size_t sz, 
T c = T()), as specified in §26.2.3.7/9 are: "This member function changes the 
length of the *this array to sz and then assigns to each element the value of 
the second argument.". To me, everything is correct.

The fact that it's different from vector is irrilevant. vector::resize does not 
change the contents of the old elements, valarray::resize does. That's what the 
standard prescribes.
------- Additional Comments From gdr@integrable-solutions.net  2003-06-13 23:41 -------
Subject: Re:  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]