On 2015–01–13, at 6:43 AM, Thiago Macieira <thi...@macieira.org> wrote:Note that the difference is whether the intrinsic functions are considered
constexpr or not. For GCC, __builtin_ldexp is constexpr but isn't for Clang:
On Tuesday 13 January 2015 09:18:13 David Krauss wrote:
> > On 2015–01–13, at 6:43 AM, Thiago Macieira <thi...@macieira.org> wrote:
> >
> > Note that the difference is whether the intrinsic functions are considered
>
> > constexpr or not. For GCC, __builtin_ldexp is constexpr but isn't for
Clang:
> For GCC, most of <cmath> is constexpr because it has supported compile-time
> evaluation of constant floating-point expressions since time immemorial.
> Only in C++11 (once constexpr extensions were forbidden) did this extension
> become nonconforming.
>
> I almost finished a paper for Urbana, “Refining floating-point constexpr,”
> but ultimately I had enough other material, and the implementations kept
> evolving under my feet. I should finish it and find a presenter for Lenexa.
> Co-authors are welcome!
I believe you should leave those functions in cmath be optionally constexpr.
Compilers do not have to make them constexpr if they are not equipped for
evaluating them at compile time, like GCC was.
For GCC, most of <cmath> is constexpr because it has supported compile-time evaluation of constant floating-point expressions since time immemorial. Only in C++11 (once constexpr extensions were forbidden) did this extension become nonconforming.
On 2015–01–13, at 11:54 AM, Myriachan <myri...@gmail.com> wrote:Is it still the case that implementations aren't allowed to declare standard functions as constexpr that are not explicitly constexpr in the Standard? What this thread is about is otherwise confusing me…sorry.
On 2015–01–13, at 11:47 AM, Richard Smith <ric...@metafoo.co.uk> wrote:One consideration, though: C supports controlling the floating point environment in various ways, and C++ pays lipservice to this by providing the <cfenv> header. If we ever start also supporting "#pragma STDC FENV_ACCESS" and following the C rules here (which seems like a very bad idea, but we're already half-way there) then that will have "interesting" interactions with compile-time evaluation of floating-point expressions.
Otherwise, whether and how expressions are contracted is implementation-defined. ** This license is specifically intended to allow implementations to exploit fast machine instructions that combine multiple C operators. As contractions potentially undermine predictability, and can even decrease accuracy for containing expressions, their use needs to be well-defined and clearly documented.
On 2015–01–14, at 5:57 AM, Richard Smith <ric...@metafoo.co.uk> wrote:(I was talking about FENV_ACCESS, not FP_CONTRACT. Dealing with FP_CONTRACT is easy; just don't do contractions in constexpr evaluation.)
On reflection, I think this goes further than <cmath>, since fesetround affects the results of (for instance) floating point addition, too. So there's no *new* problem here. =)