From ce576f6316fbabe8a3312d508fda28fb7bb17c34 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Sat, 4 Jul 2026 23:06:45 +0200 Subject: [PATCH] Fix clang-tidy avoid-c-arrays warning in write_u_escape Use a const char* rather than a char[] lookup table, matching the existing hex_bytes helper in the same file. Signed-off-by: Niels Lohmann --- include/nlohmann/detail/output/serializer.hpp | 2 +- single_include/nlohmann/json.hpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/nlohmann/detail/output/serializer.hpp b/include/nlohmann/detail/output/serializer.hpp index e2d47f75a..c8aeffbb9 100644 --- a/include/nlohmann/detail/output/serializer.hpp +++ b/include/nlohmann/detail/output/serializer.hpp @@ -694,7 +694,7 @@ class serializer std::size_t write_u_escape(std::size_t pos, std::uint16_t codeunit) noexcept { JSON_ASSERT(string_buffer.size() - pos >= 6); - static constexpr const char nibble_to_hex[] = "0123456789abcdef"; + constexpr const char* nibble_to_hex = "0123456789abcdef"; string_buffer[pos + 0] = '\\'; string_buffer[pos + 1] = 'u'; string_buffer[pos + 2] = nibble_to_hex[(codeunit >> 12u) & 0x0Fu]; diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index 6e69c8c4d..ec3ac9ebd 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -19981,7 +19981,7 @@ class serializer std::size_t write_u_escape(std::size_t pos, std::uint16_t codeunit) noexcept { JSON_ASSERT(string_buffer.size() - pos >= 6); - static constexpr const char nibble_to_hex[] = "0123456789abcdef"; + constexpr const char* nibble_to_hex = "0123456789abcdef"; string_buffer[pos + 0] = '\\'; string_buffer[pos + 1] = 'u'; string_buffer[pos + 2] = nibble_to_hex[(codeunit >> 12u) & 0x0Fu];