ECMA Wrong - Class and Object Initialization Rules - Help!



Hi,

ECMA states in Section 1.8.1.4 (Partition III) on Class and Object
Initialization Rules:

"An object constructor shall not return unless a constructor for the base
class or a different construct for the object's class has been called on the
newly constructed object. The verification algorithm shall treat the this
pointer as uninitialized unless the base class constructor has been called."

This means in particular that, if a .ctor didn't invoke a base class .ctor
but another .ctor of the same class, then the "this" pointer is not
initialized. For example, class A has 2 .ctors that invoke eachother:
recursive constructor invocation is allowed at the bytecode level!

BUT, the examples I tried show that the "this" pointer is initialized even
after invoking another .ctor of the same class - for example I can load the
"this" into a local variable.

SO, it seems to me that the "this" is considered initialized also after
invoking a ctor of the same class and NOT ONLY a ctor of the base class!

====================================

There is another issue which is not clear.

Looking in the ROTOR source, I found the following commented idea:

"If there are any locals (or arg slot 0) containing uninit vars, it is
illegal to be in a try block."

This corresponds to error "VER_E_THIS_UNINIT_EXCEP" "Uninitialized this on
entering a try block"

Beside the fact that this is not documented in ECMA, I cannot have it
confirmed by examples.

Is this verification error still checked in the current version of the
verifier?

Many thanks for any help!

George
.



Relevant Pages

  • 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: ECMA Wrong - Class and Object Initialization Rules - Help!
    ... 'Initialization' in this context has only to do with the state of the ... calling the base class constructor. ... > This means in particular that, if a .ctor didn't invoke a base class .ctor ...
    (microsoft.public.dotnet.framework.clr)
  • RE: ECMA Wrong - Class and Object Initialization Rules - Help!
    ... An instance of a class can be created only if the constructor of the class' ... > Initialization Rules: ... > pointer as uninitialized unless the base class constructor has been called." ... > This means in particular that, if a .ctor didn't invoke a base class .ctor ...
    (microsoft.public.dotnet.framework.clr)
  • Re: Me vs. MyClass
    ... >| ctor. ... > the constructor as the base constructor calls it before the derived ... > I really don't see how MyClass adds or takes away support to calling ...
    (microsoft.public.dotnet.languages.vb)
  • Re: limited types (Was: Records that could be arrays)
    ... The constructor is wrapped by the function. ... you cannot ensure the wrapper will always be called for some ... Containers of class-wide types ... own ctor, if only to call the ctor of the base class. ...
    (comp.lang.ada)