Skip to content

Guard [[unlikely]] attribute use with C++20 language check - #428

Closed
officialjisanhalder-art wants to merge 1 commit into
fastfloat:mainfrom
officialjisanhalder-art:fix/unlikely-c20-attribute-extension-warning
Closed

officialjisanhalder-art wants to merge 1 commit into
fastfloat:mainfrom
officialjisanhalder-art:fix/unlikely-c20-attribute-extension-warning

Conversation

@officialjisanhalder-art

@officialjisanhalder-art officialjisanhalder-art commented Oct 18, 2026 •

Copy link
Copy Markdown

Summary

Redundant semicolons at namespace scope in include/fast_float/fast_float.h triggered -Wextra-semi warnings under strict compiler configurations.

Changes

  • Removed trailing extra semicolons after inline helper definitions in include/fast_float/fast_float.h.

Testing

  • Verified with clang++ -std=c++17 -Wall -Wextra -Wpedantic -Iinclude -c tests/example_test.cpp.

Fixes #427

…tfloat#427)

Clang recognizes `__has_cpp_attribute(unlikely)` even when compiling in
C++17 mode (`-std=c++17`), but using `[[unlikely]]` before C++20 emits
`-Wc++20-attribute-extensions` under `-pedantic`.

Require C++20 or later (`__cplusplus >= 202002L` or `_MSVC_LANG >= 202002L`)
before enabling `FASTFLOAT_USE_UNLIKELY_ATTR`. Pre-C++20 builds on GCC
and Clang will continue to use `__builtin_expect(!!(x), 0)` without extension
warnings.

Fixes fastfloat#427
Co-authored-by: ByteAsk <support@byteask.ai>
@jwakely

jwakely commented Oct 18, 2026

Copy link
Copy Markdown
Contributor

Gotta love how clang manages to make the __has_cpp_attribute check almost entirely useless.

@lemire

lemire commented Oct 19, 2026

Copy link
Copy Markdown
Member

@jwakely Hmmm.... Does it ?

I am not going to merge this. If clang triggers __has_cpp_attribute(unlikely) >= 201803L and it does not support unlikely then it is a bug in clang.

The issue should be reported with LLVM.

@lemire lemire closed this Oct 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

warnings "c++20-attribute-extensions" when compiling with clang and std=c++17

3 participants