mirror of
https://github.com/nlohmann/json.git
synced 2026-07-09 12:05:10 +00:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 5d534dbd8e | |||
| 8917c42bbc | |||
| f3d48e4f2f | |||
| bb60941f0e |
@@ -4,6 +4,8 @@ updates:
|
||||
directory: /
|
||||
schedule:
|
||||
interval: daily
|
||||
cooldown:
|
||||
default-days: 7
|
||||
groups:
|
||||
codeql-action:
|
||||
patterns:
|
||||
@@ -13,23 +15,33 @@ updates:
|
||||
directory: /docs/mkdocs
|
||||
schedule:
|
||||
interval: daily
|
||||
cooldown:
|
||||
default-days: 7
|
||||
|
||||
- package-ecosystem: pip
|
||||
directory: /tools/astyle
|
||||
schedule:
|
||||
interval: daily
|
||||
cooldown:
|
||||
default-days: 7
|
||||
|
||||
- package-ecosystem: pip
|
||||
directory: /tools/generate_natvis
|
||||
schedule:
|
||||
interval: daily
|
||||
cooldown:
|
||||
default-days: 7
|
||||
|
||||
- package-ecosystem: pip
|
||||
directory: /tools/serve_header
|
||||
schedule:
|
||||
interval: daily
|
||||
cooldown:
|
||||
default-days: 7
|
||||
|
||||
- package-ecosystem: pip
|
||||
directory: /cmake/requirements
|
||||
schedule:
|
||||
interval: daily
|
||||
cooldown:
|
||||
default-days: 7
|
||||
|
||||
@@ -49,7 +49,7 @@ jobs:
|
||||
# SEMGREP_APP_TOKEN is still passed through so registry auth works if a
|
||||
# token is ever added.
|
||||
- name: Install Semgrep
|
||||
run: python3 -m pip install --user semgrep
|
||||
run: python3 -m pip install --user semgrep==1.168.0
|
||||
|
||||
# `semgrep scan --sarif` always exits 0 even with findings; continue-on-error
|
||||
# is a safety net so the SARIF upload still runs if the scan itself errors.
|
||||
|
||||
@@ -234,11 +234,22 @@ jobs:
|
||||
|
||||
ci_cuda_example:
|
||||
runs-on: ubuntu-latest
|
||||
container: ghcr.io/nlohmann/json-ci:v2.4.0
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
# 11.8.0: newest pre-C++20 CUDA release, exercises the C++17 fallback
|
||||
# path (tests/cuda_example/CMakeLists.txt picks the standard per nvcc
|
||||
# version); 12.1.1: permanent regression guard for #3907 (nvcc 12.0/12.1
|
||||
# choke on enable_borrowed_range at C++20, fixed in 12.2); 12.6.3: recent
|
||||
# CUDA/C++20 coverage.
|
||||
cuda: ['11.8.0', '12.1.1', '12.6.3']
|
||||
container: nvidia/cuda:${{ matrix.cuda }}-devel-ubuntu22.04
|
||||
steps:
|
||||
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
|
||||
with:
|
||||
persist-credentials: false
|
||||
- name: Get latest CMake and ninja
|
||||
uses: lukka/get-cmake@f5b8fbb4d77cec1acc5a5f9f0df4beffaf5d98d9 # v4.3.4
|
||||
- name: Run CMake
|
||||
run: cmake -S . -B build -DJSON_CI=On
|
||||
- name: Build
|
||||
|
||||
@@ -90,11 +90,13 @@ jobs:
|
||||
- name: Get latest CMake and ninja
|
||||
uses: lukka/get-cmake@f5b8fbb4d77cec1acc5a5f9f0df4beffaf5d98d9 # v4.3.4
|
||||
- name: Set extra CXX_FLAGS for latest std_version
|
||||
# /wd5285 silences C5285 emitted by the bundled third-party doctest.h, which
|
||||
# specializes std::tuple (newly diagnosed by the VS2026 v145 toolset)
|
||||
run: |
|
||||
if [ "${{ matrix.std_version }}" = "latest" ]; then
|
||||
echo "flags=/permissive- /std:c++latest /utf-8 /W4 /WX" >> $GITHUB_ENV
|
||||
echo "flags=/permissive- /std:c++latest /utf-8 /W4 /WX /wd5285" >> $GITHUB_ENV
|
||||
else
|
||||
echo "flags=/W4 /WX" >> $GITHUB_ENV
|
||||
echo "flags=/W4 /WX /wd5285" >> $GITHUB_ENV
|
||||
fi
|
||||
shell: bash
|
||||
- name: Run CMake (Release)
|
||||
|
||||
@@ -669,7 +669,6 @@ add_custom_target(ci_test_compiler_default
|
||||
add_custom_target(ci_cuda_example
|
||||
COMMAND ${CMAKE_COMMAND}
|
||||
-DCMAKE_BUILD_TYPE=Debug -GNinja
|
||||
-DCMAKE_CUDA_HOST_COMPILER=g++-8
|
||||
-S${PROJECT_SOURCE_DIR}/tests/cuda_example -B${PROJECT_BINARY_DIR}/build_cuda_example
|
||||
COMMAND ${CMAKE_COMMAND} --build ${PROJECT_BINARY_DIR}/build_cuda_example
|
||||
)
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
# -Wno-extra-semi-stmt The library uses assert which triggers this warning.
|
||||
# -Wno-padded We do not care about padding warnings.
|
||||
# -Wno-covered-switch-default All switches list all cases and a default case.
|
||||
# -Wno-unsafe-buffer-usage Otherwise library code (strlen) would not compile.
|
||||
# -Wno-unsafe-buffer-usage Otherwise Doctest would not compile.
|
||||
# -Wno-missing-noreturn We found no way to silence this warning otherwise, see PR #4871
|
||||
|
||||
set(CLANG_CXXFLAGS
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
# -Wno-aggregate-return The library uses aggregate returns.
|
||||
# -Wno-long-long The library uses the long long type to interface with system functions.
|
||||
# -Wno-namespaces The library uses namespaces.
|
||||
# -Wno-nrvo Doctest triggers this warning.
|
||||
# -Wno-padded We do not care about padding warnings.
|
||||
# -Wno-system-headers We do not care about warnings in system headers.
|
||||
# -Wno-templates The library uses templates.
|
||||
@@ -231,6 +232,7 @@ set(GCC_CXXFLAGS
|
||||
-Wnonnull
|
||||
-Wnonnull-compare
|
||||
-Wnormalized=nfkc
|
||||
-Wno-nrvo
|
||||
-Wnull-dereference
|
||||
-Wodr
|
||||
-Wold-style-cast
|
||||
|
||||
@@ -62,7 +62,9 @@ violations will result in a failed build.
|
||||
| Clang 20.1.1 | x86_64 | Ubuntu 22.04.1 LTS | GitHub |
|
||||
| Clang 20.1.8 with GNU-like command-line | x86_64 | Windows Server 2022 (Build 20348) | GitHub |
|
||||
| Clang 21.1.8 | x86_64 | Ubuntu 22.04.1 LTS | GitHub |
|
||||
| CUDA 11.0.221 (nvcc) | x86_64 | Ubuntu 20.04 LTS | GitHub |
|
||||
| CUDA 11.8.0 (nvcc) | x86_64 | Ubuntu 22.04 LTS | GitHub |
|
||||
| CUDA 12.1.1 (nvcc) | x86_64 | Ubuntu 22.04 LTS | GitHub |
|
||||
| CUDA 12.6.3 (nvcc) | x86_64 | Ubuntu 22.04 LTS | GitHub |
|
||||
| Emscripten 4.0.6 | x86_64 | Ubuntu 22.04.1 LTS | GitHub |
|
||||
| GNU 4.8.5 | x86_64 | Ubuntu 22.04.1 LTS | GitHub |
|
||||
| GNU 4.9.3 | x86_64 | Ubuntu 22.04.1 LTS | GitHub |
|
||||
|
||||
@@ -146,6 +146,11 @@
|
||||
#define JSON_HAS_RANGES 0
|
||||
#elif defined(_LIBCPP_VERSION) && _LIBCPP_VERSION < 160000
|
||||
#define JSON_HAS_RANGES 0
|
||||
// nvcc CUDA 12.0/12.1 chokes on the enable_borrowed_range variable-template
|
||||
// syntax when compiling as CUDA source; fixed in CUDA 12.2 (issue #3907)
|
||||
#elif defined(__CUDACC__) && defined(__CUDACC_VER_MAJOR__) && __CUDACC_VER_MAJOR__ == 12 \
|
||||
&& defined(__CUDACC_VER_MINOR__) && (__CUDACC_VER_MINOR__ == 0 || __CUDACC_VER_MINOR__ == 1)
|
||||
#define JSON_HAS_RANGES 0
|
||||
#elif defined(__cpp_lib_ranges)
|
||||
#define JSON_HAS_RANGES 1
|
||||
#else
|
||||
|
||||
@@ -2520,6 +2520,11 @@ JSON_HEDLEY_DIAGNOSTIC_POP
|
||||
#define JSON_HAS_RANGES 0
|
||||
#elif defined(_LIBCPP_VERSION) && _LIBCPP_VERSION < 160000
|
||||
#define JSON_HAS_RANGES 0
|
||||
// nvcc CUDA 12.0/12.1 chokes on the enable_borrowed_range variable-template
|
||||
// syntax when compiling as CUDA source; fixed in CUDA 12.2 (issue #3907)
|
||||
#elif defined(__CUDACC__) && defined(__CUDACC_VER_MAJOR__) && __CUDACC_VER_MAJOR__ == 12 \
|
||||
&& defined(__CUDACC_VER_MINOR__) && (__CUDACC_VER_MINOR__ == 0 || __CUDACC_VER_MINOR__ == 1)
|
||||
#define JSON_HAS_RANGES 0
|
||||
#elif defined(__cpp_lib_ranges)
|
||||
#define JSON_HAS_RANGES 1
|
||||
#else
|
||||
|
||||
@@ -3,7 +3,18 @@ project(json_cuda LANGUAGES CUDA)
|
||||
|
||||
add_executable(json_cuda json_cuda.cu)
|
||||
target_include_directories(json_cuda PRIVATE ../../include)
|
||||
target_compile_features(json_cuda PUBLIC cuda_std_11)
|
||||
|
||||
# nvcc added C++20 support in CUDA 12.0 and C++17 in CUDA 11.0; pick the
|
||||
# newest standard the detected compiler actually supports (see #3907)
|
||||
# instead of hard-requiring one standard for every CUDA version.
|
||||
if(CMAKE_CUDA_COMPILER_VERSION VERSION_GREATER_EQUAL 12.0)
|
||||
set(json_cuda_std 20)
|
||||
elseif(CMAKE_CUDA_COMPILER_VERSION VERSION_GREATER_EQUAL 11.0)
|
||||
set(json_cuda_std 17)
|
||||
else()
|
||||
set(json_cuda_std 11)
|
||||
endif()
|
||||
target_compile_features(json_cuda PUBLIC cuda_std_${json_cuda_std})
|
||||
set_target_properties(json_cuda PROPERTIES
|
||||
CUDA_EXTENSIONS OFF
|
||||
CUDA_STANDARD_REQUIRED ON
|
||||
|
||||
@@ -16,4 +16,20 @@ int main()
|
||||
// regression for #3013 (ordered_json::reset() compile error with nvcc)
|
||||
nlohmann::ordered_json metadata;
|
||||
metadata.erase("key");
|
||||
|
||||
// exercise comparisons (operator==/operator<=>, gated by
|
||||
// JSON_HAS_THREE_WAY_COMPARISON, independent of JSON_HAS_RANGES) and
|
||||
// range-based iteration (exercises iteration_proxy/ranges machinery
|
||||
// beyond just the enable_borrowed_range specialization) — see #3907
|
||||
nlohmann::json a = {1, 2, 3};
|
||||
nlohmann::json b = {1, 2, 3};
|
||||
static_cast<void>(a == b);
|
||||
#if JSON_HAS_THREE_WAY_COMPARISON
|
||||
static_cast<void>(a <=> b); // *NOPAD*
|
||||
static_cast<void>(a <=> 1); // *NOPAD*
|
||||
#endif
|
||||
for (const auto& element : a)
|
||||
{
|
||||
static_cast<void>(element);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -232,6 +232,9 @@ TEST_CASE("algorithms")
|
||||
// only the first four elements are expected to be sorted, the rest are
|
||||
// unspecified by the standard
|
||||
const json expected({nullptr, false, true, 3});
|
||||
// std::equal below only bounds-checks the first range; assert the
|
||||
// second range is at least as long to rule out an over-read (CWE-126)
|
||||
CHECK(std::distance(begin(expected), end(expected)) >= 4);
|
||||
CHECK(std::equal(j.begin(), j.begin() + 4, begin(expected)));
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+5108
-7121
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user