Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / March 2006

Tip: Looking for answers? Try searching our database.

Default Array Initialization Bug

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Marcus Kwok - 24 Mar 2006 03:08 GMT
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.lang.c++/msg/dab44a8b786b6a79

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

I tried to file a bug report at
http://lab.msdn.microsoft.com/productfeedback/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?

Signature

Marcus Kwok

Bruno van Dooren - 24 Mar 2006 07:53 GMT
>I found a bug in VC++ .NET 2003 regarding default initialization of
> arrays of primitives in a constructor initialization list, as detailed
[quoted text clipped - 12 lines]
>
> 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, }

Signature

Kind regards,
   Bruno van Dooren
   bruno_nos_pam_van_dooren@hotmail.com
   Remove only "_nos_pam"

Marcus Kwok - 24 Mar 2006 19:24 GMT
>>I found a bug in VC++ .NET 2003 regarding default initialization of
>> arrays of primitives in a constructor initialization list, as detailed
[quoted text clipped - 30 lines]
> 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.

Signature

Marcus Kwok

Patrick Kowalzick - 30 Mar 2006 07:46 GMT
>I found a bug in VC++ .NET 2003 regarding default initialization of
> arrays of primitives in a constructor initialization list, as detailed
[quoted text clipped - 4 lines]
> portion of the C++ Standard:
> http://groups.google.com/group/comp.lang.c++/msg/71a9fecc4f5d7d57

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
Marcus Kwok - 30 Mar 2006 16:34 GMT
>>I found a bug in VC++ .NET 2003 regarding default initialization of
>> arrays of primitives in a constructor initialization list, as detailed
[quoted text clipped - 19 lines]
>    friend std::ostream& operator<<(std::ostream& o, const Init& i);
> };

Hmm, that is interesting!  Thanks.

Signature

Marcus Kwok


Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.