Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix compilation for folly::StringPiece args (regression from v10) #4086

Closed
wants to merge 1 commit into from

Commits on Jul 24, 2024

  1. Fix compilation for folly::StringPiece args (regression from v10)

    When building fbthrift on Fedora Rawhide (which bundles fmt v11), the
    following assertion fails:
    
    ```
    /usr/include/fmt/base.h:1612:17: error: static assertion failed: Mixing character types is disallowed.
     1612 |   static_assert(formattable_char, "Mixing character types is disallowed.");
          |                 ^~~~~~~~~~~~~~~~
    /usr/include/fmt/base.h:1612:17: note: 'formattable_char' evaluates to false
    ```
    
    This happens as it's trying to format a `folly::StringPiece` argument:
    
    ```
    /usr/include/fmt/base.h: In instantiation of 'constexpr fmt::v11::detail::value<Context> fmt::v11::detail::make_arg(T&) [with bool PACKED = true; Context = fmt::v11::context; T = folly::Range<const char*>; typename std::enable_if<PACKED, int>::type <anonymous> = 0]':
    /usr/include/fmt/base.h:2003:74:   required from 'constexpr fmt::v11::detail::format_arg_store<Context, NUM_ARGS, 0, DESC> fmt::v11::make_format_args(T& ...) [with Context = context; T = {folly::Range<const char*>, folly::Range<const char*>}; long unsigned int NUM_ARGS = 2; long unsigned int NUM_NAMED_ARGS = 0; long long unsigned int DESC = 255; typename std::enable_if<(NUM_NAMED_ARGS == 0), int>::type <anonymous> = 0]'
     2003 |   return {{detail::make_arg<NUM_ARGS <= detail::max_packed_args, Context>(
          |            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
     2004 |       args)...}};
          |       ~~~~~
    ```
    
    This is ultimately caused by `folly::Range<const char*>` defining
    `value_type` as `const char`, which does not compare equal to `char`.
    
    This change is a potential fix that uses `remove_const_t` to remove
    the const-ness of `value_type` for string-like types.
    mhx committed Jul 24, 2024
    Configuration menu
    Copy the full SHA
    5a0f945 View commit details
    Browse the repository at this point in the history