You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
changed the title [-]LWG 4090. Underspecified use of locale facets for locale-dependent std::format[/-][+]LWG4090 Underspecified use of locale facets for locale-dependent std::format[/+]on May 26, 2024
Now that I've finally published a meeting summary for the 2024-06-12 SG16 meeting, I can detail the next steps for resolving this issue.
SG16 concluded that the std::numpunct facet should be used to format integer, floating-point, and bool types and that this matches existing implementation behavior for libc++, libstdc++, and MS STL as exhibited at https://godbolt.org/z/GM6Mzv6vG. This program:
Despite implementations doing the right thing, the intended behavior is under specified in the standard and [format.string.std] should be updated accordingly. A proposed resolution is needed to make further progress on this issue. I'll ask SG16 participants for a volunteer to draft wording. Once a PR materializes, I'll have SG16 confirm it matches the intent.
https://godbolt.org/z/PexbszhWs extends the example to show a custom num_put facet which is not used by the std::format calls (but is used when writing to a stream directly after imbuing the stream with the locale). This confirms that implementations use numpunct directly, not via num_put.
Activity
[-]LWG 4090. Underspecified use of locale facets for locale-dependent std::format[/-][+]LWG4090 Underspecified use of locale facets for locale-dependent std::format[/+]tahonermann commentedon Nov 18, 2024
SG16 discussed this issue during its 2024-06-12 meeting. No polls were taken. SG16 will review again in the new year.
tahonermann commentedon Jun 11, 2025
Now that I've finally published a meeting summary for the 2024-06-12 SG16 meeting, I can detail the next steps for resolving this issue.
SG16 concluded that the
std::numpunct
facet should be used to format integer, floating-point, and bool types and that this matches existing implementation behavior for libc++, libstdc++, and MS STL as exhibited at https://godbolt.org/z/GM6Mzv6vG. This program:produces the following output for all three implementations.
Despite implementations doing the right thing, the intended behavior is under specified in the standard and [format.string.std] should be updated accordingly. A proposed resolution is needed to make further progress on this issue. I'll ask SG16 participants for a volunteer to draft wording. Once a PR materializes, I'll have SG16 confirm it matches the intent.
jwakely commentedon Jun 12, 2025
https://godbolt.org/z/PexbszhWs extends the example to show a custom
num_put
facet which is not used by thestd::format
calls (but is used when writing to a stream directly after imbuing the stream with the locale). This confirms that implementations usenumpunct
directly, not vianum_put
.