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
Compiler:
Any compiler that does not support to_chars for double , i.e. for which TOML_FLOATING_POINT_CHARCONV is 0.
C++ standard mode (e.g. 17, 20, 'latest'):
17
Target arch (e.g. x64):
Not relevant.
Exceptions enabled:
Not relevant.
Relevant toml++ configuration customizations:
Not relevant.
Relevant compilation flags:
Not relevant.
Describe the bug
When TOML_FLOATING_POINT_CHARCONVstd::ostringstream is used to convert a double to a string in https://github.com/marzer/tomlplusplus/blob/v1.1.0/include/toml++/toml_parser_impl.h#L153 . However, the imbue method is not called, so the default locale, that is the global C++ locale set in https://en.cppreference.com/w/cpp/locale/locale/global . If it is intended to have the same behavior independently from the value TOML_FLOATING_POINT_CHARCONV, I guess it is necessary to call ss.imbue(std::locale::classic()); after the ss object is declared. I did not checked other code paths if TOML_FLOATING_POINT_CHARCONV is set to 0, but it is possible that they are affected as well.
@traversaro I've implemented a fix locally but in testing some additional locale machinery I uncovered a few other related issues, which I'll fix tomorrow before pushing anything.
@traversaro The fix for this is live now. Solving this forced me to learn about locales on unix and to add different locales to my CI pipeline, so any locale-based regressions should be caught in future.
Thanks a lot. I reported these kind of locale-related bugs to several open source projects over the years, but I never saw something as complete as the testing infrastructure that you set up!
Environment
Compiler:
Any compiler that does not support
to_chars
fordouble
, i.e. for whichTOML_FLOATING_POINT_CHARCONV
is 0.C++ standard mode (e.g. 17, 20, 'latest'):
17
Target arch (e.g. x64):
Not relevant.
Exceptions enabled:
Not relevant.
Relevant
toml++
configuration customizations:Not relevant.
Relevant compilation flags:
Not relevant.
Describe the bug
When
TOML_FLOATING_POINT_CHARCONV
std::ostringstream
is used to convert a double to a string in https://github.com/marzer/tomlplusplus/blob/v1.1.0/include/toml++/toml_parser_impl.h#L153 . However, theimbue
method is not called, so the default locale, that is the global C++ locale set in https://en.cppreference.com/w/cpp/locale/locale/global . If it is intended to have the same behavior independently from the valueTOML_FLOATING_POINT_CHARCONV
, I guess it is necessary to callss.imbue(std::locale::classic());
after thess
object is declared. I did not checked other code paths ifTOML_FLOATING_POINT_CHARCONV
is set to 0, but it is possible that they are affected as well.Additional information
Related issues:
cc @S-Dafarra @GiulioRomualdi
The text was updated successfully, but these errors were encountered: