[clang-tools-extra] [clang-tidy] add modernize-use-constexpr check (PR #146553)
Julian Schmidt via cfe-commits
cfe-commits at lists.llvm.org
Wed Jul 2 07:33:55 PDT 2025
5chmidti wrote:
> Another compiler error after transformation:
>
> It made this constexpr:
>
> ```c++
> PUGI_IMPL_FN constexpr bool is_nan(double value)
> {
> #if defined(PUGI_IMPL_MSVC_CRT_VERSION) || defined(__BORLANDC__)
> return !!_isnan(value);
> #elif defined(fpclassify) && defined(FP_NAN)
> return fpclassify(value) == FP_NAN;
> #else
> // fallback
> const volatile double v = value;
> return v != v;
> #endif
> }
> ```
>
> But then:
>
> ```
> /Users/sean/external/VTK/ThirdParty/pugixml/vtkpugixml/src/pugixml.cpp:8413:30: error: constexpr function never produces a constant expression [-Winvalid-constexpr]
> 8413 | PUGI_IMPL_FN constexpr bool is_nan(double value)
> | ^~~~~~
> /Users/sean/external/VTK/ThirdParty/pugixml/vtkpugixml/src/pugixml.cpp:8422:15: note: read of volatile-qualified type 'const volatile double' is not allowed in a constant expression
> 8422 | return v != v;
> | ^
> ```
I'll take a look
https://github.com/llvm/llvm-project/pull/146553
More information about the cfe-commits
mailing list