Topic: Time of initialization of non-local objects, 3.6.2p3


Author: algrant@myrealbox.com (Al Grant)
Date: Wed, 6 Aug 2003 16:07:34 +0000 (UTC)
Raw View
3.6.2p3 says about dynamic initialization of objects with namespace
scope:
  "... If the initialization is deferred to some point in time
   after the first statement of main, it shall occur before the
   first use of any function or object defined in the same
   translation unit as the object to be initialized."

Presumably if no object in that translation unit is used the only
requirement (from 3.7.1) is that if the program terminates normally,
the initialization must happen before that time?

Also, the wording implies that if a translation unit with a
dynamically
initialized object defines an inline function, which is also defined
elsewhere, uses of that function (anywhere) will require the unit's
objects to have been initialized.  The function is, after all, defined
in that translation unit (among others).  Surely that cannot be
intended?  Should it be interpreted to mean "defined only"?

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html                       ]