duckdb / duckdb-r

The duckdb R package
https://r.duckdb.org/
Other
121 stars 24 forks source link

Use proper std::isnan in C++ code, not C99 versions which may not compile #152

Open barracuda156 opened 5 months ago

barracuda156 commented 5 months ago
rfuns.cpp: In function 'int32_t duckdb::rfuns::{anonymous}::cast(T, duckdb::ValidityMask&, duckdb::idx_t) [with T = double; int32_t = int; duckdb::idx_t = long long unsigned int]':
rfuns.cpp:111:13: error: 'isnan' was not declared in this scope; did you mean 'std::isnan'?
  111 |         if (isnan(input)) {
      |             ^~~~~
      |             std::isnan
In file included from /opt/local/include/LegacySupport/cmath:54,
                 from duckdb/third_party/fast_float/fast_float/fast_float.h:1518,
                 from duckdb/src/include/duckdb/common/operator/double_cast_operator.hpp:12,
                 from rfuns.cpp:84:
/opt/local/include/gcc13/c++/cmath:1192:5: note: 'std::isnan' declared here
 1192 |     isnan(_Tp __x)
      |     ^~~~~
rfuns.cpp: In function 'void duckdb::rfuns::isna_double(duckdb::DataChunk&, duckdb::ExpressionState&, duckdb::Vector&)':
rfuns.cpp:231:57: error: 'isnan' was not declared in this scope; did you mean 'std::isnan'?
  231 |                                 result_data[base_idx] = isnan(data[base_idx]);
      |                                                         ^~~~~
      |                                                         std::isnan
/opt/local/include/gcc13/c++/cmath:1192:5: note: 'std::isnan' declared here
 1192 |     isnan(_Tp __x)
      |     ^~~~~
rfuns.cpp:244:65: error: 'isnan' was not declared in this scope; did you mean 'std::isnan'?
  244 |                                         result_data[base_idx] = isnan(data[base_idx]);
      |                                                                 ^~~~~
      |                                                                 std::isnan
/opt/local/include/gcc13/c++/cmath:1192:5: note: 'std::isnan' declared here
 1192 |     isnan(_Tp __x)
      |     ^~~~~
rfuns.cpp: In function 'bool duckdb::rfuns::{anonymous}::set_null(T, duckdb::ValidityMask&, duckdb::idx_t) [with T = double; duckdb::idx_t = long long unsigned int]':
rfuns.cpp:630:13: error: 'isnan' was not declared in this scope; did you mean 'std::isnan'?
  630 |         if (isnan(value)) {
      |             ^~~~~
      |             std::isnan
/opt/local/include/gcc13/c++/cmath:1192:5: note: 'std::isnan' declared here
 1192 |     isnan(_Tp __x)
      |     ^~~~~
make: *** [rfuns.o] Error 1
barracuda156 commented 5 months ago

Once #include <cmath> is added and isnan replaced with std::isnan, rfuns.cpp compiles fine.

krlmlr commented 5 months ago

Thanks. @romainfrancois: Can you please take a look?

krlmlr commented 4 months ago

Done in 31c49e7a95c9302a55c0d74c679f5ec6c6ef5902.

barracuda156 commented 4 months ago

@krlmlr We are back to having it broken ))

Now this is also needed: https://github.com/macports/macports-ports/blob/39c348b38f909764a7b76de406467d0ca48a9a00/R/R-duckdb/files/patch-fix-cmath.diff

krlmlr commented 3 months ago

I'm changing this for the imminent CRAN 1.0.0-1, the issue is closed when upstream duckdb-rfuns (that's vendored into this package) brings this in.

barracuda156 commented 3 months ago

@krlmlr Thanks!