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++ / July 2006

Tip: Looking for answers? Try searching our database.

VC++ compiler warning C4345

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Bit Byte - 27 Jul 2006 10:36 GMT
I have the following warning:

warning C4345: behavior change: an object of POD type constructed with
an initializer of the form () will be default-initialized

Should I care (if yes, why?)
Should I worry (if no, under what conditions should I worry ? - if yes why?)

I looked on the MS site for help with this warning but the examples
giving are pretty scant and info about this (via Google) is generally
scant ...
adebaene@club-internet.fr - 27 Jul 2006 11:21 GMT
> I have the following warning:
>
[quoted text clipped - 7 lines]
> giving are pretty scant and info about this (via Google) is generally
> scant ...

Show us a minimal code snippet that give you this warning....

Arnaud
MVP  -VC
Bo Persson - 27 Jul 2006 16:19 GMT
>I have the following warning:
>
> warning C4345: behavior change: an object of POD type constructed
> with an initializer of the form () will be default-initialized
>
> Should I care (if yes, why?)

Yes, because this is what the compiler should do.

> Should I worry (if no, under what conditions should I worry ? - if
> yes why?)

No, it is actually an improvement, as this is required by the
standard. Earlier versions did't do it right, or was produced before
there was a standard.

Bo Persson
Doug Harrison [MVP] - 27 Jul 2006 16:25 GMT
>I have the following warning:
>
>warning C4345: behavior change: an object of POD type constructed with
>an initializer of the form () will be default-initialized
>
>Should I care (if yes, why?)

This means it will be zero-initialized, as required by the standard. For
example, the following should cause the created objects to be
zero-initialized:

int* p = new int();

struct X
{
  int x;
};

X* q = new X();

However, the following syntax (note the lack of parens) leaves the
variables uninitialized;

int* p = new int;
X* q = new X;

>Should I worry (if no, under what conditions should I worry ? - if yes why?)

It sounds like you weren't expecting any particular value (and if you were,
the only one you had any right to expect was zero, in which case, be happy,
because now you'll get it reliably), so zero should be as good as any. The
only downside is that it takes a little extra code to accomplish this.

Signature

Doug Harrison
Visual C++ MVP


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.