<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/60781>60781</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
__FLT_EVAL_METHOD__ is set to -1 with Ofast.
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
davemgreen
</td>
</tr>
</table>
<pre>
On linux, math.h includes this:
```
/* Get __GLIBC_FLT_EVAL_METHOD. */
#include <bits/flt-eval-method.h>
#ifdef __USE_ISOC99
/* Define the following typedefs.
float_t floating-point type at least as wide as `float' used
to evaluate `float' expressions
double_t floating-point type at least as wide as `double' used
to evaluate `double' expressions
*/
# if __GLIBC_FLT_EVAL_METHOD == 0 || __GLIBC_FLT_EVAL_METHOD == 16
typedef float float_t;
typedef double double_t;
# elif __GLIBC_FLT_EVAL_METHOD == 1
typedef double float_t;
typedef double double_t;
# elif __GLIBC_FLT_EVAL_METHOD == 2
typedef long double float_t;
typedef long double double_t;
# elif __GLIBC_FLT_EVAL_METHOD == 32
typedef _Float32 float_t;
typedef double double_t;
# elif __GLIBC_FLT_EVAL_METHOD == 33
typedef _Float32x float_t;
typedef _Float32x double_t;
# elif __GLIBC_FLT_EVAL_METHOD == 64
typedef _Float64 float_t;
typedef _Float64 double_t;
# elif __GLIBC_FLT_EVAL_METHOD == 65
typedef _Float64x float_t;
typedef _Float64x double_t;
# elif __GLIBC_FLT_EVAL_METHOD == 128
typedef _Float128 float_t;
typedef _Float128 double_t;
# elif __GLIBC_FLT_EVAL_METHOD == 129
typedef _Float128x float_t;
typedef _Float128x double_t;
# else
# error "Unknown __GLIBC_FLT_EVAL_METHOD"
# endif
#endif
```
bits/flt-eval-method.h is this:
```
#ifdef __FLT_EVAL_METHOD__
# if __FLT_EVAL_METHOD__ == -1
# define __GLIBC_FLT_EVAL_METHOD 2
# else
# define __GLIBC_FLT_EVAL_METHOD __FLT_EVAL_METHOD__
# endif
#elif defined __x86_64__
# define __GLIBC_FLT_EVAL_METHOD 0
#else
# define __GLIBC_FLT_EVAL_METHOD 2
#endif
```
After https://reviews.llvm.org/D109239 with clang with -Ofast, __FLT_EVAL_METHOD__ gets a value of -1, meaning it is set by that to 2 and we end up using long double for float_t and double_t.
https://godbolt.org/z/PqsxrxYqn
>From the comments in D109239 it doesn't appear it was expected to be used in this way. It created an ABI break for float_t and double_t types, along with using the very inefficient long double types on some architectures.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy0VlFv4jgQ_jXmZUSUOBCShzy0UPYq7akn7e5J9xSZZEJ8a2zWnhR6v_7kBFpg4XLb1UpVEzefv2_mm6nHwjm51og5m96z6WIkWmqMzSvxjJu1RdSjlale8icNSup2z_gcNoKaoAGpS9VW6IAa6Vh8x8IFC-9YEh5--iVfMn4HH5CgKD58fLyfF8uPn4uHP-8-Fr8_fP7taREA4x3sgI8PvMDi-UqSY3xZKxrjs1DjDVJjqqBh8cMB_rqprrCGovjy6aF4_PQ0z7Iz_QXWUiNQg1AbpcxO6jXQyxYrrF1wygUAUCsjqCAWZt2b1Ovx1khN3Q4QBAqFIxAOdrJC_2RJ2EEZn0HrsDoyZizMyIAPvhWEZzjcby06J412B-nKtCuFPyrc7_ofym_A76QvSgCyvlUuYPGCxQsIgc3mbDYfwkVJz3owu_f21eH4_vxrH-KbEcfvPiZUw1FFV-l-lRo_p1NGr4ckTzHv1o0vhIulV4v5L0s0jq8L7m8qviHeLZpMrlEmkwHNZPITktPrjEN5esT7e5an1zgjng6oesRPqGY3OIeS7SA3dB2-rQCtNRYY51_0V212-lZIjPMTDl3J-nV5uroYLN3vWwMC5NBYep0YF8EUxcUp-N33o4Pj6CTXqh8wtzIMM37TpsGt_xnjhV--8j1hBUWxT5MimZzCB8XCE67TMH8gwaGi3dWEFhqibVcfP6GXFp8l7lyg1PMmMHbN-HIRhRmPM9hJaqBUQq_71_FTLRz5i8i14qyRHAj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