Skip to content

[C++][FlightRPC][ODBC] Clang 20 compiles failed on macOS 26 #50756

Closed

Description

@HuaHuaY

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

There are four kinds of compile errors.

  1. Incorrect initialization way.
[build] cpp/src/arrow/flight/sql/odbc/odbc_impl/accessors/timestamp_array_accessor.cc:98:20: error: missing field 'tm_min' initializer [-Werror,-Wmissing-field-initializers]
[build]    98 |   tm timestamp = {0};
[build]       | 
  1. Used deprecated standard library APIs std::wstring_convert and std::codecvt_utf8.
[build] In file included from cpp/src/arrow/flight/sql/odbc/odbc_impl/encoding.cc:18:
[build] In file included from cpp/src/arrow/flight/sql/odbc/odbc_impl/encoding.h:23:
[build] /nix/store/4b6hc41dl32baac3vwy7xa29xzz14rzp-libcxx-20.1.8-dev/include/c++/v1/locale:3226:1: error: 'wstring_convert<std::codecvt_utf8<char16_t>, char16_t>' is deprecated [-Werror,-Wdeprecated-declarations]
[build]  3226 | wstring_convert<_Codecvt, _Elem, _WideAlloc, _ByteAlloc>::to_bytes(const _Elem* __frm, const _Elem* __frm_end) {
[build]       | ^
[build] cpp/src/arrow/flight/sql/odbc/odbc_impl/encoding.h:111:32: note: in instantiation of member function 'std::wstring_convert<std::codecvt_utf8<char16_t>, char16_t>::to_bytes' requested here
[build]   111 |   auto byte_string = converter.to_bytes((CHAR_TYPE*)wcs_string,
[build]       |                                ^
[build] cpp/src/arrow/flight/sql/odbc/odbc_impl/encoding.h:126:14: note: in instantiation of function template specialization 'arrow::flight::sql::odbc::WcsToUtf8<char16_t>' requested here
[build]   126 |       return WcsToUtf8<char16_t>(wcs_string, length_in_code_units, result);
[build]       |              ^
[build] /nix/store/4b6hc41dl32baac3vwy7xa29xzz14rzp-libcxx-20.1.8-dev/include/c++/v1/locale:3083:28: note: 'wstring_convert<std::codecvt_utf8<char16_t>, char16_t>' has been explicitly marked deprecated here
[build]  3083 | class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 wstring_convert {
[build]       |                            ^
[build] /nix/store/4b6hc41dl32baac3vwy7xa29xzz14rzp-libcxx-20.1.8-dev/include/c++/v1/__config:725:41: note: expanded from macro '_LIBCPP_DEPRECATED_IN_CXX17'
[build]   725 | #    define _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_DEPRECATED
[build]       |                                         ^
[build] /nix/store/4b6hc41dl32baac3vwy7xa29xzz14rzp-libcxx-20.1.8-dev/include/c++/v1/__config:698:49: note: expanded from macro '_LIBCPP_DEPRECATED'
[build]   698 | #      define _LIBCPP_DEPRECATED __attribute__((__deprecated__))
[build]       |
  1. Implicit conversion loses integer precision.
[build] cpp/src/arrow/flight/sql/odbc/odbc_impl/odbc_descriptor.cc:489:49: error: implicit conversion loses integer precision: 'size_t' (aka 'unsigned long') to 'int' [-Werror,-Wshorten-64-to-32]
[build]   489 |     int16_t concise_type = rsmd->GetConciseType(one_based_index);
[build]       |
  1. Unused private field.
[build] In file included from cpp/src/arrow/flight/sql/odbc/odbc_impl/flight_sql_connection.cc:18:
[build] cpp/src/arrow/flight/sql/odbc/odbc_impl/flight_sql_connection.h:50:15: error: private field 'odbc_version_' is not used [-Werror,-Wunused-private-field]
[build]    50 |   OdbcVersion odbc_version_;
[build]       |               ^
[build] 1 error generated.

Component(s)

C++, FlightRPC

Activity

  1. HuaHuaY commented on Jul 31, 2026

    @HuaHuaY
    ContributorAuthor

    The second error is not easy to fix. We have these code which use deprecated std::wstring_convert and std::codecvt_utf8. #46622 (issue GH-46576) tried to suppress compilation errors by adding ARROW_SUPPRESS_DEPRECATION_WARNING. But at least in my local environment, this error no longer occurs at the template definition, but rather where the template is actually instantiated.

    // GH-46576: suppress unicode warnings
    ARROW_SUPPRESS_DEPRECATION_WARNING
    template <typename CHAR_TYPE>
    inline void WcsToUtf8(const void* wcs_string, size_t length_in_code_units,
                          std::vector<uint8_t>* result) {
      thread_local std::wstring_convert<std::codecvt_utf8<CHAR_TYPE>, CHAR_TYPE> converter;
      auto byte_string = converter.to_bytes((CHAR_TYPE*)wcs_string,
                                            (CHAR_TYPE*)wcs_string + length_in_code_units);
    
      uint32_t length_in_bytes = static_cast<uint32_t>(byte_string.size());
      const uint8_t* data = (uint8_t*)byte_string.data();
    
      result->reserve(length_in_bytes);
      result->assign(data, data + length_in_bytes);
    }
    ARROW_UNSUPPRESS_DEPRECATION_WARNING

    I think there are two ways to fix this:

    1. Wrap the #include <codecvt> and #include <locale> statements in encoding.h with ARROW_SUPPRESS_DEPRECATION_WARNING. Additionally, any code that includes both encoding.h and <locale> must include encoding.h first. This is necessary because the deprecation warning must be suppressed the moment the compiler encounters <locale> within the compilation unit. This is inconvenient, as headers like <vector> also internally include <locale>; effectively, if a compilation unit depends—directly or transitively—on encoding.h, encoding.h must be manually included at the very top of the source file.
    2. Replace this standard library API with the Boost boost::locale::conv::utf_to_utf.

    @kou @alinaliBQ @lidavidm Please take a look. What do you think about this?

  2. HuaHuaY commented on Jul 31, 2026

    @HuaHuaY
    ContributorAuthor

    I lean towards Option 2 and have submitted a PR. If there are reasons why we cannot choose Option 2, I can adjust the PR's behavior accordingly.

  3. alinaliBQ commented on Jul 31, 2026

    @alinaliBQ
    Collaborator

    Hi @HuaHuaY, thank you for submitting this issue and looking into it! I'll defer to David and kou on the use of Boost, but as far as I know, we're generally trying to avoid implementations from Boost where possible.

  4. lidavidm commented on Aug 3, 2026

    @lidavidm
    Member

    I don't know if we've really written down why we don't use Boost, but generally we prefer to avoid the dependency where possible.

    We already vendor utfcpp. Is that sufficient?

  5. HuaHuaY commented on Aug 3, 2026

    @HuaHuaY
    ContributorAuthor

    We already vendor utfcpp. Is that sufficient?

    I have replaced with utfcpp.

  6. kou commented on Aug 3, 2026

    @kou
    Member

    +1 for utfcpp.

  7. added a commit that references this issue on Aug 5, 2026
  8. added this to the 26.0.0 milestone on Aug 5, 2026
  9. lidavidm commented on Aug 5, 2026

    @lidavidm
    Member

    Issue resolved by pull request 50757
    #50757

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions