https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80432
Bug ID: 80432 Summary: std::pow gives wrong results for long double arguments Product: gcc Version: 7.0.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: theivorytower at gmail dot com Target Milestone: --- With the latest gcc 7.0.1, whenever I pass long double arguments to std::pow, the results are either nan or inf for most of the times. For example, the following simple code outputs -nan while the expected result is 2: #include <cmath> #include <iostream> int main() { long double a = 4; long double b = 0.5; std::cout << std::pow(a, b) << std::endl; } If I set = 0.007 and b = 0.2, the output is inf while the expected result is 0.370697. The program behaves as expected if the arguments are double instead of long double. The following is my gcc version info: Using built-in specs. COLLECT_GCC=g++ COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-linux-gnu/7.0.1/lto-wrapper Target: x86_64-pc-linux-gnu Configured with: /home/hao/installers/aur-gcc-git/src/gcc/configure --prefix=/usr --libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=https://bugs.archlinux.org/ --enable-languages=c,c++,lto --enable-shared --enable-threads=posix --enable-libmpx --with-system-zlib --with-isl --enable-__cxa_atexit --disable-libunwind-exceptions --enable-clocale=gnu --disable-libstdcxx-pch --disable-libssp --enable-gnu-unique-object --enable-linker-build-id --enable-lto --enable-plugin --enable-install-libiberty --with-linker-hash-style=gnu --enable-gnu-indirect-function --disable-multilib --disable-werror --enable-checking=release Thread model: posix gcc version 7.0.1 20170413 (experimental) (GCC)