Skip to content

[R] Compile with -Wconversion on clang15 results in compiler warnings #39138

@paleolimbot

Description

@paleolimbot

Describe the bug, including details regarding any error messages, version, and platform.

As identified by the CRAN M1 check: https://www.stats.ox.ac.uk/pub/bdr/M1mac/arrow.log

A few are in cpp11 headers:

In file included from /Users/ripley/R/Library/cpp11/include/cpp11/as.hpp:11:
/Users/ripley/R/Library/cpp11/include/cpp11/protect.hpp:130:29: warning: implicit conversion loses integer precision: 'unsigned long' to 'int' [-Wshorten-64-to-32]
  return std::forward<F>(f)(std::get<I>(std::move(a))...);
         ~~~                ^~~~~~~~~~~~~~~~~~~~~~~~~
/Users/ripley/R/Library/cpp11/include/cpp11/protect.hpp:136:10: note: in instantiation of function template specialization 'cpp11::detail::apply<SEXPREC *(*&)(const char *, int, cetype_t), const char *&&, unsigned long &&, cetype_t &&, 0UL, 1UL, 2UL>' requested here
  return apply(std::forward<F>(f), std::move(a), make_index_sequence<sizeof...(Aref)>{});
         ^
/Users/ripley/R/Library/cpp11/include/cpp11/protect.hpp:149:12: note: in instantiation of function template specialization 'cpp11::detail::apply<SEXPREC *(*&)(const char *, int, cetype_t), const char *&&, unsigned long &&, cetype_t &&>' requested here
    return apply(ptr_, std::move(arefs_));
           ^
/Users/ripley/R/Library/cpp11/include/cpp11/protect.hpp:56:16: note: in instantiation of member function 'cpp11::detail::closure<SEXPREC *(const char *, int, cetype_t), const char *&&, unsigned long &&, cetype_t &&>::operator()' requested here
        return static_cast<Fun&&>(*callback)();
               ^
/Users/ripley/R/Library/cpp11/include/cpp11/protect.hpp:163:14: note: in instantiation of function template specialization 'cpp11::unwind_protect<cpp11::detail::closure<SEXPREC *(const char *, int, cetype_t), const char *&&, unsigned long &&, cetype_t &&>, void>' requested here
      return unwind_protect(
             ^
/Users/ripley/R/Library/cpp11/include/cpp11/r_string.hpp:20:35: note: in instantiation of function template specialization 'cpp11::protect::function<SEXPREC *(const char *, int, cetype_t)>::operator()<const char *, unsigned long, cetype_t>' requested here
      : data_(safe[Rf_mkCharLenCE](data.c_str(), data.size(), CE_UTF8)) {}
                                  ^
In file included from table.cpp:18:
././arrow_types.h:206:16: warning: implicit conversion loses integer precision: 'R_xlen_t' (aka 'long') to 'int' [-Wshorten-64-to-32]
        lambda(j, x_i[k], names_x_i[k]);
        ~~~~~~ ^
././arrow_types.h:218:3: note: in instantiation of function template specialization 'arrow::r::TraverseDots<(lambda at ././arrow_types.h:217:14)>' requested here
  TraverseDots(dots, num_fields, set);
  ^
././arrow_types.h:209:14: warning: implicit conversion loses integer precision: 'R_xlen_t' (aka 'long') to 'int' [-Wshorten-64-to-32]
      lambda(j, dots[i], name_i);
      ~~~~~~ ^
././arrow_types.h:206:16: warning: implicit conversion loses integer precision: 'R_xlen_t' (aka 'long') to 'int' [-Wshorten-64-to-32]
        lambda(j, x_i[k], names_x_i[k]);
        ~~~~~~ ^
table.cpp:182:13: note: in instantiation of function template specialization 'arrow::r::TraverseDots<(lambda at table.cpp:170:28)>' requested here
  arrow::r::TraverseDots(lst, num_fields, extract_one_field);
            ^
In file included from table.cpp:18:
././arrow_types.h:209:14: warning: implicit conversion loses integer precision: 'R_xlen_t' (aka 'long') to 'int' [-Wshorten-64-to-32]
      lambda(j, dots[i], name_i);
      ~~~~~~ ^
././arrow_types.h:206:16: warning: implicit conversion loses integer precision: 'R_xlen_t' (aka 'long') to 'int' [-Wshorten-64-to-32]
        lambda(j, x_i[k], names_x_i[k]);
        ~~~~~~ ^
table.cpp:213:13: note: in instantiation of function template specialization 'arrow::r::TraverseDots<(lambda at table.cpp:203:31)>' requested here
  arrow::r::TraverseDots(lst, num_fields, extract_one_metadata);
            ^
In file included from table.cpp:18:
././arrow_types.h:209:14: warning: implicit conversion loses integer precision: 'R_xlen_t' (aka 'long') to 'int' [-Wshorten-64-to-32]
      lambda(j, dots[i], name_i);
      ~~~~~~ ^
22 warnings generated.

In file included from /Users/ripley/R/Library/cpp11/include/cpp11.hpp:5:
/Users/ripley/R/Library/cpp11/include/cpp11/as.hpp:104:16: warning: implicit conversion turns floating-point number into integer: 'double' to 'enable_if_integral<long long, long long>' (aka 'long long') [-Wfloat-conversion]
        return value;
        ~~~~~~ ^~~~~
io.cpp:238:25: note: in instantiation of function template specialization 'cpp11::as_cpp<long long>' requested here
          return cpp11::as_cpp<int64_t>(result);
                        ^
15 warnings generated.

In file included from json.cpp:18:
In file included from ././arrow_types.h:22:
In file included from ././arrow_cpp11.h:25:
In file included from /Users/ripley/R/Library/cpp11/include/cpp11.hpp:7:
In file included from /Users/ripley/R/Library/cpp11/include/cpp11/data_frame.hpp:12:
In file included from /Users/ripley/R/Library/cpp11/include/cpp11/list.hpp:7:
In file included from /Users/ripley/R/Library/cpp11/include/cpp11/named_arg.hpp:9:
/Users/ripley/R/Library/cpp11/include/cpp11/sexp.hpp:79:36: warning: implicit conversion turns floating-point number into integer: 'double' to 'size_t' (aka 'unsigned long') [-Wfloat-conversion]
  operator size_t() const { return REAL_ELT(data_, 0); }
                            ~~~~~~ ^~~~~~~~~~~~~~~~~~
In file included from json.cpp:18:
In file included from ././arrow_types.h:22:
In file included from ././arrow_cpp11.h:25:
In file included from /Users/ripley/R/Library/cpp11/include/cpp11.hpp:7:
/Users/ripley/R/Library/cpp11/include/cpp11/data_frame.hpp:48:14: warning: implicit conversion loses integer precision: 'R_xlen_t' (aka 'long') to 'int' [-Wshorten-64-to-32]
      return Rf_xlength(nms);
      ~~~~~~ ^~~~~~~~~~~~~~~
/Users/ripley/R/Library/cpp11/include/cpp11/data_frame.hpp:55:12: warning: implicit conversion loses integer precision: 'R_xlen_t' (aka 'long') to 'int' [-Wshorten-64-to-32]
    return Rf_xlength(VECTOR_ELT(x, 0));
    ~~~~~~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~

A few are in Arrow C++ headers:

In file included from RTasks.cpp:18:
In file included from ././r_task_group.h:20:
In file included from /Users/ripley/R/packages/tests-devel/arrow/libarrow/arrow-14.0.0/include/arrow/util/parallel.h:25:
In file included from /Users/ripley/R/packages/tests-devel/arrow/libarrow/arrow-14.0.0/include/arrow/util/thread_pool.h:32:
In file included from /Users/ripley/R/packages/tests-devel/arrow/libarrow/arrow-14.0.0/include/arrow/util/future.h:32:
In file included from /Users/ripley/R/packages/tests-devel/arrow/libarrow/arrow-14.0.0/include/arrow/type_traits.h:26:
/Users/ripley/R/packages/tests-devel/arrow/libarrow/arrow-14.0.0/include/arrow/util/bit_util.h:338:84: warning: implicit conversion loses integer precision: 'int' to 'unsigned char' [-Wimplicit-int-conversion]
  return (static_cast<Word>(i < sizeof(Word) * 8) << (i & (sizeof(Word) * 8 - 1))) - 1;
  ~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
/Users/ripley/R/packages/tests-devel/arrow/libarrow/arrow-14.0.0/include/arrow/util/bit_util.h:340:15: note: in instantiation of function template specialization 'arrow::bit_util::PrecedingWordBitmask<unsigned char>' requested here
static_assert(PrecedingWordBitmask<uint8_t>(0) == 0x00, "");
              ^
/Users/ripley/R/packages/tests-devel/arrow/libarrow/arrow-14.0.0/include/arrow/util/bit_util.h:338:84: warning: implicit conversion loses integer precision: 'int' to 'unsigned short' [-Wimplicit-int-conversion]
  return (static_cast<Word>(i < sizeof(Word) * 8) << (i & (sizeof(Word) * 8 - 1))) - 1;
  ~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
/Users/ripley/R/packages/tests-devel/arrow/libarrow/arrow-14.0.0/include/arrow/util/bit_util.h:343:15: note: in instantiation of function template specialization 'arrow::bit_util::PrecedingWordBitmask<unsigned short>' requested here
static_assert(PrecedingWordBitmask<uint16_t>(8) == 0x00ff, "");
              ^
/Users/ripley/R/packages/tests-devel/arrow/libarrow/arrow-14.0.0/include/arrow/util/bit_util.h:361:64: warning: implicit conversion loses integer precision: 'uint32_t' (aka 'unsigned int') to 'uint8_t' (aka 'unsigned char') [-Wimplicit-int-conversion]
              values[4] << 4 | values[5] << 5 | values[6] << 6 | values[7] << 7);
              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~
3 warnings generated.

In file included from io.cpp:23:
In file included from /Users/ripley/R/packages/tests-devel/arrow/libarrow/arrow-14.0.0/include/arrow/buffer_builder.h:30:
/Users/ripley/R/packages/tests-devel/arrow/libarrow/arrow-14.0.0/include/arrow/util/bitmap_generate.h:95:35: warning: implicit conversion loses integer precision: 'int' to 'uint8_t' (aka 'unsigned char') [-Wimplicit-int-conversion]
              out_results[6] << 6 | out_results[7] << 7);
              ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~
/Users/ripley/R/packages/tests-devel/arrow/libarrow/arrow-14.0.0/include/arrow/buffer_builder.h:369:15: note: in instantiation of function template specialization 'arrow::internal::GenerateBitsUnrolled<(lambda at /Users/ripley/R/packages/tests-devel/arrow/libarrow/arrow-14.0.0/include/arrow/buffer_builder.h:369:79)>' requested here
    internal::GenerateBitsUnrolled(mutable_data(), bit_length_, num_elements, [&] {
   

Component(s)

R

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions