This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/20427] [3.4 Regression] 'new int [2] ()' not default initialized
- From: "redi at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 19 Aug 2005 22:06:36 -0000
- Subject: [Bug c++/20427] [3.4 Regression] 'new int [2] ()' not default initialized
- References: <20050311163320.20427.andrew.stubbs@st.com>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Additional Comments From redi at gcc dot gnu dot org 2005-08-19 22:06 -------
I see a similar problem with uninitialized elements of an array with a new
initializer, but on mainline and 4.0.
#include <iostream>
void f(int n)
{
int * a = new int [n] () ;
for (int i = 0; i < n; ++i)
{
std::cout << a[i]++ << ' ';
}
std::cout << '\n';
delete[] a;
}
int main()
{
f(5);
f(5);
f(5);
f(5);
}
With mainline build from today I see:
0 0 0 0 0
0 0 1 1 1
0 0 2 2 2
0 0 3 3 3
Each line should also be all 0s because the new initializer should default-init
all the elements, but some of the elements have not been reset after they were
set during the first function call.
Should I file a different bug, or is this the same problem but unseen until now
on 4.x?
--
What |Removed |Added
----------------------------------------------------------------------------
CC| |redi at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20427