diff --git a/Makefile b/Makefile index b53d8d3dcd..4c96bad7f3 100644 --- a/Makefile +++ b/Makefile @@ -66,6 +66,9 @@ fuzz: test/src/fuzz.cpp src/json.hpp cppcheck: cppcheck --enable=warning --inconclusive --force --std=c++11 src/json.hpp --error-exitcode=1 +clang_sanitize: clean + CXX=clang++ CXXFLAGS="-g -O2 -fsanitize=address -fsanitize=undefined -fno-omit-frame-pointer" $(MAKE) + ########################################################################## # maintainer targets ########################################################################## diff --git a/src/json.hpp b/src/json.hpp index b5e24206be..d6f8925fc2 100644 --- a/src/json.hpp +++ b/src/json.hpp @@ -2232,7 +2232,8 @@ class basic_json { std::stringstream ss; // fix locale problems - ss.imbue(std::locale(std::locale(), new DecimalSeparator)); + const static std::locale loc(std::locale(), new DecimalSeparator); + ss.imbue(loc); // 6, 15 or 16 digits of precision allows round-trip IEEE 754 // string->float->string, string->double->string or string->long diff --git a/src/json.hpp.re2c b/src/json.hpp.re2c index fdc0063870..75fc27e5a6 100644 --- a/src/json.hpp.re2c +++ b/src/json.hpp.re2c @@ -2232,7 +2232,8 @@ class basic_json { std::stringstream ss; // fix locale problems - ss.imbue(std::locale(std::locale(), new DecimalSeparator)); + const static std::locale loc(std::locale(), new DecimalSeparator); + ss.imbue(loc); // 6, 15 or 16 digits of precision allows round-trip IEEE 754 // string->float->string, string->double->string or string->long