473,399 Members | 3,888 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

Default Array Initialization Bug

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
4 1563
>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
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
>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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Steven T. Hatton | last post by:
I mistakenly set this to the comp.std.c++ a few days back. I don't believe it passed the moderator's veto - and I did not expect or desire anything different. But the question remains: ISO/IEC...
10
by: JKop | last post by:
What's the difference between them? Take the following: #include <iostream> struct Blah { int k;
16
by: Steven T. Hatton | last post by:
As far as I know, there is no way to provide a default value for the argument to the constructor A::A(char (&array)) in this example. Correct? struct A{ A(char (&array) ){...
8
by: Peter B. Steiger | last post by:
The latest project in my ongoing quest to evolve my brain from Pascal to C is a simple word game that involves stringing together random lists of words. In the Pascal version the whole array was...
15
by: Charles Sullivan | last post by:
Assume I have a static array of structures the elements of which could be any conceivable mixture of C types, pointers, arrays. And this array is uninitialized at program startup. If later in...
12
by: Edward Diener | last post by:
Given value class X { public: // Not allowed: X():i(100000),s(10000) { } // Allowed void InitializeDefaults() { i = 100000; s = 10000; } private: int i;
10
by: utab | last post by:
Dear all, Can somebody direct me to some resources on the subject or explain the details in brief? I checked the FAQ but could not find or maybe missed. Regards,
23
by: Jess | last post by:
Hello, I understand the default-initialization happens if we don't initialize an object explicitly. I think for an object of a class type, the value is determined by the constructor, and for...
4
by: Jess | last post by:
Hello, I tried several books to find out the details of object initialization. Unfortunately, I'm still confused by two specific concepts, namely default-initialization and...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.