RE: Value class initialization rules

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



George,

Initially, for valuetypes, the rules used to be that each and every valuetype needed to be initiazlied by calling the .ctor, but now we are not as strict and make
no guarantess. Hence, it is not a requirement for a valuetype .ctor to initialize every field.

Also, we now require initlocals to be set for verifiable code so VER_E_THIS_UNINIT_V_RET could be a non-issue any longer.

Thanks,
Diana
--------------------
>Thread-Topic: Value class initialization rules
>thread-index: AcU5rzBZxWs8lx/IT56qCQBzW/ZUTQ==
>X-WBNR-Posting-Host: 129.132.1.4
>From: =?Utf-8?B?R2Vvcmdl?= <George@xxxxxxxxxxxxxxxxxxxxxxxxx>
>References: <2B7EE3DC-76F6-4C4F-A110-A8892A8B8F71@xxxxxxxxxxxxx> <BsEIeKYOFHA.5096@xxxxxxxxxxxxxxxxxxxxx>
>Subject: RE: Value class initialization rules
>Date: Tue, 5 Apr 2005 00:15:04 -0700
>Lines: 34
>Message-ID: <96330760-B9D0-4858-A13D-2A6CADDB1574@xxxxxxxxxxxxx>
>MIME-Version: 1.0
>Content-Type: text/plain;
> charset="Utf-8"
>Content-Transfer-Encoding: 7bit
>X-Newsreader: Microsoft CDO for Windows 2000
>Content-Class: urn:content-classes:message
>Importance: normal
>Priority: normal
>X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
>Newsgroups: microsoft.public.dotnet.framework.clr
>NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.1.29
>Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGXA03.phx.gbl
>Xref: TK2MSFTNGXA01.phx.gbl microsoft.public.dotnet.framework.clr:3442
>X-Tomcat-NG: microsoft.public.dotnet.framework.clr
>
>Diana, thank you for the message.
>
>> Value types do not have "this" pointer.
>
>In ECMA, I found many paragraphs where the value types have a "this" pointer
>and I have no doubt about it.
>
>Here is a paragraph from Partition I, chapter 8.9.7 "Value Type Definition":
>
>"When a non-static method (i.e. an instance or virtual method) is called on
>the value type its this pointer is a managed reference to the instance"
>
>More exactly, the type of the "this" pointer for a value class "vc" is the
>managed pointer "vc&".
>
>My question was referring to the exact time when the "this" pointer in a
>.ctor is considered initialized.
>
>For example, "this" is not considered initialized upon exiting an object
>class ".ctor" that didn't call the base ".ctor". This is one verification
>rule.
>
>My question relative to value classes was triggered after looking at the
>error messages that a verifier can throw. They can be found in the file
>"mscorrc.rc" in Rotor.
>
>It's about this error message: VER_E_THIS_UNINIT_V_RET "Return from ctor
>before all fields are initialized".
>
>When exactly is thrown this error?
>
>Thank you.
>Cheers,
>George
>


--

This posting is provided "AS IS" with no warranties, and confers no rights. Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm

Note: For the benefit of the community-at-large, all responses to this message are best directed to the newsgroup/thread from which they originated.

.



Relevant Pages

  • Re: Using Reference of Pointers
    ... > force initialisation of objects through their static function Create, ... I think hiding a pointer behind a typedef like this ... why not do the initialization in the ctor as C++ ...
    (comp.lang.cpp)
  • ECMA Wrong - Class and Object Initialization Rules - Help!
    ... ECMA states in Section 1.8.1.4 on Class and Object ... Initialization Rules: ... "An object constructor shall not return unless a constructor for the base ... if a .ctor didn't invoke a base class .ctor ...
    (microsoft.public.dotnet.framework.clr)
  • Re: is such exception handling approach good?
    ... There is nothing wrong with throwing from constructor. ... Say if a class initializes some memory, ... an oracle database in the ctor then what should you do with the object ... However if you instead have split up the initialization in three ...
    (microsoft.public.vc.language)
  • Re: another dumb question?!
    ... > Like any ctor, a copy ctor performs initialization. ... > Initialization!= assignment; ... > declaration statement, this is initialization, not assignment: ...
    (microsoft.public.vc.mfc)
  • Re: Why cant I initialize member pointers to 0 in class declaration?
    ... > Good idea, wrong syntax. ... Initialization is done in the constructors: ... > But shouldn't the ctor be giving them useful values? ...
    (alt.comp.lang.learn.c-cpp)