From 5c8d0af5cea8614b1b48ad382550748651154582 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Sat, 10 Jul 2021 12:50:59 +0200 Subject: [PATCH 1/4] :memo: add comment for handling of negative zeros #2854 --- doc/mkdocs/docs/features/types/number_handling.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/doc/mkdocs/docs/features/types/number_handling.md b/doc/mkdocs/docs/features/types/number_handling.md index 4224c155b2..aa8df7ad86 100644 --- a/doc/mkdocs/docs/features/types/number_handling.md +++ b/doc/mkdocs/docs/features/types/number_handling.md @@ -96,6 +96,21 @@ This is the same behavior as the code `#!c double x = 3.141592653589793238462643 - All integers outside the range $[-2^{63}, 2^{64}-1]$, as well as floating-point numbers are stored as `double`. This also concurs with the specification above. +### Zeros + +The JSON number grammar allows for different ways to express zero, and this library will store zeros differently: + +| Literal | Stored value and type | Serialization | +| ------- | --------------------- | ------------- | +| `0` | `#!c std::uint64_t(0)` | `0` | +| `-0` | `#!c std::int64_t(0)` | `0` | +| `0.0` | `#!c double(0.0)` | `0.0` | +| `-0.0` | `#!c double(-0.0)` | `-0.0` | +| `0E0` | `#!c double(0.0)` | `0.0` | +| `-0E0` | `#!c double(-0.0)` | `-0.0` | + +That is, `-0` is stored as a signed integer, but the serialization does not reproduce the `-`. + ### Number serialization - Integer numbers are serialized as is; that is, no scientific notation is used. From a82f66beed60cab657a909be7eb9192dbcb3982f Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Sat, 10 Jul 2021 12:51:18 +0200 Subject: [PATCH 2/4] :memo: document JSON_NO_IO macro #2842 --- doc/mkdocs/docs/features/macros.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/doc/mkdocs/docs/features/macros.md b/doc/mkdocs/docs/features/macros.md index ee401c5dcd..d008393f76 100644 --- a/doc/mkdocs/docs/features/macros.md +++ b/doc/mkdocs/docs/features/macros.md @@ -32,6 +32,10 @@ When defining `JSON_NOEXCEPTION`, `#!cpp try` is replaced by `#!cpp if (true)`, The same effect is achieved by setting the compiler flag `-fno-exceptions`. +## `JSON_NO_IO` + +When defined, headers ``, ``, ``, ``, and `` are not included and parse functions relying on these headers are excluded. This is relevant for environment where these I/O functions are disallowed for security reasons (e.g., Intel Software Guard Extensions (SGX)). + ## `JSON_SKIP_UNSUPPORTED_COMPILER_CHECK` When defined, the library will not create a compile error when a known unsupported compiler is detected. This allows to use the library with compilers that do not fully support C++11 and may only work if unsupported features are not used. From 7442c24662dd97fbbf12077b1dfa1aa0da8258ea Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Sat, 10 Jul 2021 13:44:13 +0200 Subject: [PATCH 3/4] :rotating_light: suppress missingReturn warnings --- cmake/ci.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/ci.cmake b/cmake/ci.cmake index d7d94b2bf8..e2d175d411 100644 --- a/cmake/ci.cmake +++ b/cmake/ci.cmake @@ -560,7 +560,7 @@ add_custom_target(ci_clang_analyze ############################################################################### add_custom_target(ci_cppcheck - COMMAND ${CPPCHECK_TOOL} --enable=warning --inline-suppr --inconclusive --force --std=c++11 ${PROJECT_SOURCE_DIR}/single_include/nlohmann/json.hpp --error-exitcode=1 + COMMAND ${CPPCHECK_TOOL} --enable=warning --suppress=missingReturn --inline-suppr --inconclusive --force --std=c++11 ${PROJECT_SOURCE_DIR}/single_include/nlohmann/json.hpp --error-exitcode=1 COMMENT "Check code with Cppcheck" ) From 249688037fab6144bb0279aeed687efcde4b3baa Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Sun, 11 Jul 2021 09:33:43 +0200 Subject: [PATCH 4/4] :alembic: fix coverage --- cmake/ci.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmake/ci.cmake b/cmake/ci.cmake index e2d175d411..84cbfe4c22 100644 --- a/cmake/ci.cmake +++ b/cmake/ci.cmake @@ -467,7 +467,7 @@ add_custom_target(ci_test_diagnostics ############################################################################### add_custom_target(ci_test_coverage - COMMAND CXX=${GCC_TOOL} ${CMAKE_COMMAND} + COMMAND CXX=g++ ${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE=Debug -GNinja -DCMAKE_CXX_FLAGS="--coverage;-fprofile-arcs;-ftest-coverage" -DJSON_BuildTests=ON -DJSON_MultipleHeaders=ON -S${PROJECT_SOURCE_DIR} -B${PROJECT_BINARY_DIR}/build_coverage @@ -475,7 +475,7 @@ add_custom_target(ci_test_coverage COMMAND cd ${PROJECT_BINARY_DIR}/build_coverage && ${CMAKE_CTEST_COMMAND} --parallel ${N} --output-on-failure COMMAND ${LCOV_TOOL} --directory . --capture --output-file json.info --rc lcov_branch_coverage=1 - COMMAND ${LCOV_TOOL} -e json.info ${SRC_FILES} --output-file json.info.filtered --gcov-tool ${GCOV_TOOL} --rc lcov_branch_coverage=1 + COMMAND ${LCOV_TOOL} -e json.info ${SRC_FILES} --output-file json.info.filtered --rc lcov_branch_coverage=1 COMMAND ${CMAKE_SOURCE_DIR}/test/thirdparty/imapdl/filterbr.py json.info.filtered > json.info.filtered.noexcept COMMAND genhtml --title "JSON for Modern C++" --legend --demangle-cpp --output-directory html --show-details --branch-coverage json.info.filtered.noexcept