From 5d534dbd8e32a1aa42dcd4e02e952914c4df280f Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Thu, 9 Jul 2026 09:34:36 +0200 Subject: [PATCH] Fix ci_cuda_example CUDA 11.8 build after C++17 fallback (#3907) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The 11.8.0 leg's graceful C++17 fallback (added in the previous commit) worked correctly, but the broadened smoke test used the <=> operator unconditionally, which isn't valid syntax pre-C++20 — nvcc rejected it with "expected an expression" once the CMake logic picked cuda_std_17 for the older toolkit. Gate those two lines behind JSON_HAS_THREE_WAY_COMPARISON like the library itself does internally. Sanity-compiled the file as plain C++ at both -std=c++17 (skips the guarded block) and -std=c++20 (includes it) locally; the actual nvcc build is verified via CI on PR #5248. Signed-off-by: Niels Lohmann --- tests/cuda_example/json_cuda.cu | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/cuda_example/json_cuda.cu b/tests/cuda_example/json_cuda.cu index be9f7eca2..76d631fa4 100644 --- a/tests/cuda_example/json_cuda.cu +++ b/tests/cuda_example/json_cuda.cu @@ -24,8 +24,10 @@ int main() nlohmann::json a = {1, 2, 3}; nlohmann::json b = {1, 2, 3}; static_cast(a == b); +#if JSON_HAS_THREE_WAY_COMPARISON static_cast(a <=> b); // *NOPAD* static_cast(a <=> 1); // *NOPAD* +#endif for (const auto& element : a) { static_cast(element);