From b1fbfe932a3bb3626ecc70b923ce82833d706d3f Mon Sep 17 00:00:00 2001 From: Daniel Lemire Date: Sun, 7 Jun 2026 11:18:09 -0400 Subject: [PATCH] silencing -Wc++20-extensions at the point of use solely --- include/fast_float/float_common.h | 11 ----------- include/fast_float/parse_number.h | 9 ++++++++- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/include/fast_float/float_common.h b/include/fast_float/float_common.h index 479febc..73a92fe 100644 --- a/include/fast_float/float_common.h +++ b/include/fast_float/float_common.h @@ -212,18 +212,7 @@ using parse_options = parse_options_t; #endif #ifdef FASTFLOAT_USE_UNLIKELY_ATTR -// We have to disable -Wc++20-extensions for the [[unlikely]] attribute -// See comment for @jwakely at -// https://github.com/fastfloat/fast_float/pull/387#discussion_r3366943539 -// This is unfortunate. -#ifdef __clang__ -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wc++20-extensions" -#endif #define fastfloat_unlikely(x) (x) [[unlikely]] -#ifdef __clang__ -#pragma clang diagnostic pop -#endif #elif defined(__GNUC__) || defined(__clang__) #define fastfloat_unlikely(x) (__builtin_expect(!!(x), 0)) #else diff --git a/include/fast_float/parse_number.h b/include/fast_float/parse_number.h index 1071573..5ec13e0 100644 --- a/include/fast_float/parse_number.h +++ b/include/fast_float/parse_number.h @@ -351,6 +351,11 @@ from_chars_float_advanced(UC const *first, UC const *last, T &value, // Slow path A (rare): > 19 significant digits. The no-span parse left the // mantissa un-truncated and skipped the span-based recompute; the cold helper // re-parses with spans and runs the full algorithm. + // +// We have to disable -Wc++20-extensions for the [[unlikely]] attribute +// See comment for @jwakely at +// https://github.com/fastfloat/fast_float/pull/387#discussion_r3366943539 +// This is unfortunate. #ifdef __clang__ #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wc++20-extensions" @@ -358,7 +363,9 @@ from_chars_float_advanced(UC const *first, UC const *last, T &value, if fastfloat_unlikely (pns.too_many_digits) { return parse_number_slow_path(first, last, value, options, bjf); } - +#ifdef __clang__ +#pragma clang diagnostic pop +#endif answer.ec = std::errc(); // be optimistic answer.ptr = pns.lastmatch;