[PATCH v4] math.h: Do not use __MATH_TG_BUILTIN_CLASSIFY for C++

Adhemerval Zanella Netto adhemerval.zanella@linaro.org
Tue Jan 13 14:02:27 GMT 2026



On 13/01/26 09:32, Adhemerval Zanella Netto wrote:
> 
> 
> On 13/01/26 07:09, Florian Weimer wrote:
>> * Adhemerval Zanella:
>>
>>> The __MATH_TG_BUILTIN_CLASSIFY macro can not be used in C++ mode because
>>> it might use __builtin_types_compatible_p, which is a C-only builtin.
>>>
>>> C++ code might use the math.h definitions in two different ways: either
>>> by including cmath or math.h.  For the former, the C++ library will
>>> usually disable and override math.h definitions, and it usually expects
>>> fpclassify/isinf to be implemented as macros.  And switching to functions
>>> with overloaded arguments might break the libstdc++ bootstrap.
>>>
>>> For the latter, we still need to provide an implementation, and the
>>> built-in is the straightforward one (as previously done before
>>> __MATH_TG_BUILTIN_CLASSIFY introduction).
>>>
>>> Checked with bmg targeting x86_64-linux-gnu and on x86_64-linux-gnu and
>>> aarch64 with gcc-15 and clang-18.
>>> --
>>> Changes from v3:
>>> * Only use __builtin if compiler supports it.
>>> Changes from v2:
>>> * Make test-builtin-denormal-cxx.cc xfail.
>>> * Fixed commit title.
>>
>> I think we should revert the two commits from December.  If the GCC
>> builtins are broken, then GCC should be fixed.  Especially since we have
>> to use them in C++ mode anyway.
> 
> This patch aims to restore the previous C++ definitions used on math.h,
> so C++ cmath itself could either fix itself the denormal issue.
> 
> Also, the original fix was to provide a working math.h definition that
> works on both gcc *and* clang, fixing the builtin on gcc only partially
> fixes the underlying issue (since clang has the same problem). And it
> does not help when math.h is used with older gccs.
> 

I will send patches to revert the previous changes and drop this patchset.


More information about the Libc-alpha mailing list