This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of New status.

4192. §[ios.base.cons] ios_base members may not have indeterminate values after construction

Section: 31.5.2.8 [ios.base.cons], 31.5.2.4 [ios.base.locales] Status: New Submitter: S. B. Tam Opened: 2025-01-12 Last modified: 2025-01-18

Priority: Not Prioritized

View all other issues in [ios.base.cons].

View all issues with New status.

Discussion:

31.5.2.8 [ios.base.cons] specifies that

Each ios_base member has an indeterminate value after construction.

However

In either case, the constructor cannot cause the members to have indeterminate values after construction.

A related problem is that 31.5.2.4 [ios.base.locales] requires ios_base::getloc to return:

If no locale has been imbued, a copy of the global C++ locale, locale(), in effect at the time of construction.

However, according to 31.5.2.8 [ios.base.cons], the corresponding member is not initialized until basic_ios::init is called.

Proposed resolution:

This wording is relative to N5001.

  1. Modify 31.5.2.4 [ios.base.locales] as indicated:

    ios_base();
    

    -1- Effects: Each ios_base member has an unspecified (possibly indeterminate or erroneous) value after construction. The object's members shall be initialized by calling basic_ios::init before the object's first use or before it is destroyed, whichever comes first; otherwise the behavior is undefined.

  2. Modify 31.5.2.8 [ios.base.cons] as indicated:

    locale getloc() const;
    

    -4- Returns: If no locale has been imbued, a copy of the global C++ locale, locale(), in effect at the time of constructionthe last basic_ios::init call on the current object. Otherwise, returns the imbued locale, to be used to perform locale-dependent input and output operations.