This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libstdc++/78851] Resolve DR 550 in cmath and continue using __builtin_powil() even in C++11


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78851

--- Comment #2 from Vadim Zeitlin <vz-gcc at zeitlins dot org> ---
Sorry if I misunderstood but what exactly am I misinterpreting? Looking at the
code (and comment) at
https://github.com/gcc-mirror/gcc/blob/6514c52372bb36e555843b0419d71cf55eda0409/libstdc++-v3/include/c_global/cmath#L395
I thought that this check was supposed to be temporary and could be removed now
that the DR 550 has been resolved without requiring these functions to be
removed. If this is supposed to be the permanent solution then at least the
comment and the defect marker should be removed, shouldn't it?

However it seems to me that it would be better to remove the check. Not because
some code doesn't currently compile, but because the generated code with
-std=c++11 is different (certainly) and suboptimal (probably) than with
-std=c++98. E.g. if you compile and run this program

---------------------------------- >8 --------------------------------------
#include <cmath>
#include <stdio.h>

void f(long double x) {
    int n = -10;

    printf("%.40Lf\n", std::pow(x, n));
}

int main() {
    f(10.0L);
}
---------------------------------- >8 --------------------------------------

with gcc version 6.2.0 (i686-win32-sjlj-rev1, Built by MinGW-W64 project),
it will output 0.0000000001000000000000000000018377930496 in C++98 mode but
0.0000000001000000000000000000397031165002 in C++11.

Moreover, looking at the generated assembly, in C++98 the result is computed
directly with a few multiplication and a single inverse operation, which seems
to be consistent with __builtin_powil() being used. However in C++11 mode there
is a call to _powl() instead.

Wouldn't it be better to continue to use __builtin_powil() even in C++11? If
not, this should be just closed, of course, but I'd appreciate it if you could
please explain why. TIA!

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]