Microsoft KB Archive/101188: Difference between revisions

From BetaArchive Wiki
(importing KB archive)
 
m (Text replacement - "&" to "&")
 
Line 52: Line 52:
In addition to not relying on the order of initialization, you should not use one object's address in another object's initialization when the two objects are contained in different translation units.<br />
In addition to not relying on the order of initialization, you should not use one object's address in another object's initialization when the two objects are contained in different translation units.<br />
<br />
<br />
AT&amp;T 2.1 does not define the order of initialization for global objects across translation units. The order of initialization is implementation-dependent.
AT&T 2.1 does not define the order of initialization for global objects across translation units. The order of initialization is implementation-dependent.


</div>
</div>

Latest revision as of 11:24, 21 July 2020

Knowledge Base


Order of Object Initialization Across Translation Units

Article ID: 101188

Article Last Modified on 12/1/2003



APPLIES TO

  • Microsoft C/C++ Professional Development System 7.0
  • Microsoft Visual C++ 1.0 Professional Edition
  • Microsoft Visual C++ 1.5 Professional Edition
  • Microsoft Visual C++ 2.0 Professional Edition
  • Microsoft Visual C++ 4.0 Standard Edition



This article was previously published under Q101188

SUMMARY

The order of initialization of global objects is undefined across translation units. For example, if your application consists of three C++ modules and each module declares an object of xyz class, there is no guarantee during program initialization which of these objects will be constructed first.

In addition to not relying on the order of initialization, you should not use one object's address in another object's initialization when the two objects are contained in different translation units.

AT&T 2.1 does not define the order of initialization for global objects across translation units. The order of initialization is implementation-dependent.


Additional query words: kbinf 7.00 1.00 1.50 2.00 4.00

Keywords: kblangcpp KB101188