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.
ios_base
members may not have indeterminate values after constructionSection: 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
If the ios_base
object has static storage duration, the members would have been zero-initialized.
If the ios_base
object has automatic storage duration, the members would have erroneous values.
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] requiresios_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.
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 callingbasic_ios::init
before the object's first use or before it is destroyed, whichever comes first; otherwise the behavior is undefined.
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 ofconstructionthe lastbasic_ios::init
call on the current object. Otherwise, returns the imbued locale, to be used to perform locale-dependent input and output operations.