By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,852 Members | 2,123 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,852 IT Pros & Developers. It's quick & easy.

Default Array Initialization Bug

P: n/a
I found a bug in VC++ .NET 2003 regarding default initialization of
arrays of primitives in a constructor initialization list, as detailed
in this post:
http://groups.google.com/group/comp....b44a8b786b6a79

and in the reply by Dietmar Kuehl, in which he quotes the relevant
portion of the C++ Standard:
http://groups.google.com/group/comp....a9fecc4f5d7d57

I tried to file a bug report at
http://lab.msdn.microsoft.com/produc...k/default.aspx
but they only let you submit bug reports for VC++ 2005, which I am
unable to install at the moment, and I am not sure if the bug is present
in the newer version.

Can anybody confirm if this bug is present in the newer version?

--
Marcus Kwok
Mar 24 '06 #1
Share this Question
Share on Google+
4 Replies


P: n/a
>I found a bug in VC++ .NET 2003 regarding default initialization of
arrays of primitives in a constructor initialization list, as detailed
in this post:
http://groups.google.com/group/comp....b44a8b786b6a79

and in the reply by Dietmar Kuehl, in which he quotes the relevant
portion of the C++ Standard:
http://groups.google.com/group/comp....a9fecc4f5d7d57

I tried to file a bug report at
http://lab.msdn.microsoft.com/produc...k/default.aspx
but they only let you submit bug reports for VC++ 2005, which I am
unable to install at the moment, and I am not sure if the bug is present
in the newer version.

Can anybody confirm if this bug is present in the newer version?

This is the output when compiled with VC2005

During compilation:
warning C4351: new behavior: elements of array 'Init::ai' will be default
initialized
warning C4351: new behavior: elements of array 'Init::bi' will be default
initialized

When running

UnInit:
ai = {-858993460, -858993460, -858993460, -858993460, }
bi = {204, 204, 204, 204, }

Init:
ai = {0, 0, 0, 0, }
bi = {0, 0, 0, 0, }
--

Kind regards,
Bruno van Dooren
br**********************@hotmail.com
Remove only "_nos_pam"
Mar 24 '06 #2

P: n/a
Bruno van Dooren <br**********************@hotmail.com> wrote:
I found a bug in VC++ .NET 2003 regarding default initialization of
arrays of primitives in a constructor initialization list, as detailed
in this post:
http://groups.google.com/group/comp....b44a8b786b6a79

and in the reply by Dietmar Kuehl, in which he quotes the relevant
portion of the C++ Standard:
http://groups.google.com/group/comp....a9fecc4f5d7d57

I tried to file a bug report at
http://lab.msdn.microsoft.com/produc...k/default.aspx
but they only let you submit bug reports for VC++ 2005, which I am
unable to install at the moment, and I am not sure if the bug is present
in the newer version.

Can anybody confirm if this bug is present in the newer version?


This is the output when compiled with VC2005

During compilation:
warning C4351: new behavior: elements of array 'Init::ai' will be default
initialized
warning C4351: new behavior: elements of array 'Init::bi' will be default
initialized

When running

UnInit:
ai = {-858993460, -858993460, -858993460, -858993460, ^H^H}
bi = {204, 204, 204, 204, ^H^H}

Init:
ai = {0, 0, 0, 0, ^H^H}
bi = {0, 0, 0, 0, ^H^H}


I see, so they fixed it in the new version. Thanks for checking this
for me, and I will not file a bug report.

--
Marcus Kwok
Mar 24 '06 #3

P: n/a
>I found a bug in VC++ .NET 2003 regarding default initialization of
arrays of primitives in a constructor initialization list, as detailed
in this post:
http://groups.google.com/group/comp....b44a8b786b6a79

and in the reply by Dietmar Kuehl, in which he quotes the relevant
portion of the C++ Standard:
http://groups.google.com/group/comp....a9fecc4f5d7d57


Funny enough the following change works as expected:

struct Init_POD
{
int ai[Size];
bool bi[Size];
};

class Init {
Init_POD pods;
public:
Init() : pods() { }
friend std::ostream& operator<<(std::ostream& o, const Init& i);
};

std::ostream&
operator<<(std::ostream& o, const Init& in)
{
o << "Init:\n";
o << "ai = {";
std::copy(in.pods.ai, in.pods.ai + Size, std::ostream_iterator<int>(o,
", "));
o << "\b\b}\n";

o << "bi = {";
std::copy(in.pods.bi, in.pods.bi + Size, std::ostream_iterator<bool>(o,
", "));
o << "\b\b}";

return o;
}

Regards,
Patrick
Mar 30 '06 #4

P: n/a
Patrick Kowalzick <pa***************@mapandguide.de> wrote:
I found a bug in VC++ .NET 2003 regarding default initialization of
arrays of primitives in a constructor initialization list, as detailed
in this post:
http://groups.google.com/group/comp....b44a8b786b6a79

and in the reply by Dietmar Kuehl, in which he quotes the relevant
portion of the C++ Standard:
http://groups.google.com/group/comp....a9fecc4f5d7d57


Funny enough the following change works as expected:

struct Init_POD
{
int ai[Size];
bool bi[Size];
};

class Init {
Init_POD pods;
public:
Init() : pods() { }
friend std::ostream& operator<<(std::ostream& o, const Init& i);
};


Hmm, that is interesting! Thanks.

--
Marcus Kwok
Mar 30 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.