This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 110b. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.

2023-01-15


1187. Problems in initialization example

Section: 6.9.3.2  [basic.start.static]     Status: C++11     Submitter: Jason Merrill     Date: 2010-08-31

[Voted into the WP at the March, 2011 meeting.]

The note in 6.9.3.2 [basic.start.static] paragraph 3 contains the following example:

  inline double fd() { return 1.0; }
  extern double d1;
  double d2 = d1;     // unspecified:
                      // may be statically initialized to 0.0 or
                      // dynamically initialized to 1.0
  double d1 = fd();   // may be initialized statically to 1.0

The comment for d2 overlooks the third possibility: if both d1 and d2 are dynamically initialized, d2 will be initialized to 0.

Proposed resolution (November, 2010):

Change the comments in the example in 6.9.3.2 [basic.start.static] paragraph 3 as follows:

  inline double fd() { return 1.0; }
  extern double d1;
  double d2 = d1;     // unspecified:
                      // may be statically initialized to 0.0 or
                      // dynamically initialized to 1.0 to 0.0 if d1 is dynamically initialized, or 1.0 otherwise
  double d1 = fd();   // may be initialized statically or dynamically to 1.0

(The note should also be in running text following the bulleted list instead of appearing as a bulleted item, as well.)