bitwiseworks / gcc-os2

Port of GCC compiler to OS/2
GNU General Public License v2.0
16 stars 2 forks source link

std::nearbyint returns `nan` for any argument #30

Closed dmik closed 3 years ago

dmik commented 3 years ago

std::nearbyint is a modern rounding function in C++.

This following program:

#include <iostream>
#include <cmath>

int main()
{
  double d1 = 127.00000;
  std::cout << d1 << ' ' << std::nearbyint(d1) << '\n';
  return 0;
}

outputs 127 nan instead of 127 127 for some reason.

Note that any other double instead of 127 results in nan as well.

Spotted here: https://github.com/bitwiseworks/qtwebengine-chromium-os2/issues/21#issuecomment-691239455.

dmik commented 3 years ago

Well, C++ just forwards these calls to libc, so it should be fixed there. Created https://github.com/bitwiseworks/libc/issues/87 and will close this one.

I spotted another problem though. An attempt to include fails with multiple errors. Created #31 for it.