lntue wrote:

> @lntue, it seems to me that rounding modes other than 
> `FE_TONEAREST`/`FE_DYNAMIC` causes the evaluation to fail; is this expected?:
> 
> ```
> $ clang++ -xc++ -<<<'_Pragma("STDC FENV_ROUND FE_TOWARDZERO") constexpr auto 
> x = __builtin_expf(-1.f);'
> <stdin>:1:1: warning: pragma STDC FENV_ROUND is not supported 
> [-Wunknown-pragmas]
>     1 | _Pragma("STDC FENV_ROUND FE_TOWARDZERO") constexpr auto x = 
> __builtin_expf(-1.f);
>       | ^
> <scratch space>:4:31: note: expanded from here
>     4 |  STDC FENV_ROUND FE_TOWARDZERO
>       |                               ^
> <stdin>:1:57: error: constexpr variable 'x' must be initialized by a constant 
> expression
>     1 | _Pragma("STDC FENV_ROUND FE_TOWARDZERO") constexpr auto x = 
> __builtin_expf(-1.f);
>       |                                                         ^   
> ~~~~~~~~~~~~~~~~~~~~
> 1 warning and 1 error generated.
> ```

@hubert-reinterpretcast:  it is because of the current limitation I put on 
`APFloat::exp` since I don't want to mess with the host's floating point 
environment:
https://github.com/llvm/llvm-project/blob/main/llvm/lib/Support/APFloat.cpp#L6140
We are working on adding static rounding mode math functions that are 
integer-only without touching the host's floating point environment in LLVM 
libc, and we will use those to support constant evaluation for other rounding 
modes.  WDYT?

https://github.com/llvm/llvm-project/pull/199808
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to