Skip to content

Error in static_assert for std::ranges::contiguous_range for rust::Slice on MacOSΒ #1535

@Patrick-6

Description

@Patrick-6

We are running into a compilation error in CI on MacOS with cxx version 1.0.160 with c++20.

The failure happens in this static_assert with the following error:

In file included from /Applications/Xcode_15.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/__iterator/concepts.h:34:
/Applications/Xcode_15.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/__memory/pointer_traits.h:118:22: error: implicit instantiation of undefined template 'std::__pointer_traits_element_type<rust::Slice<const unsigned char>::iterator>'
    typedef typename __pointer_traits_element_type<pointer>::type    element_type;
                     ^
/Applications/Xcode_15.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/__memory/pointer_traits.h:182:20: note: in instantiation of template class 'std::pointer_traits<rust::Slice<const unsigned char>::iterator>' requested here
    decltype((void)pointer_traits<_Pointer>::to_address(std::declval<const _Pointer&>()))
                   ^
/Applications/Xcode_15.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/__memory/pointer_traits.h:195:59: note: during template argument deduction for class template partial specialization '_HasToAddress<_Pointer, decltype((void)pointer_traits<_Pointer>::to_address(std::declval<const _Pointer &>()))>' [with _Pointer = rust::Slice<const unsigned char>::iterator]
  static const bool value = _HasArrow<_Pointer>::value || _HasToAddress<_Pointer>::value;
                                                          ^
/Applications/Xcode_15.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/__memory/pointer_traits.h:195:59: note: in instantiation of template class 'std::_HasToAddress<rust::Slice<const unsigned char>::iterator>' requested here
/Applications/Xcode_15.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/__type_traits/conjunction.h:27:32: note: in instantiation of template class 'std::_IsFancyPointer<rust::Slice<const unsigned char>::iterator>' requested here
__expand_to_true<__enable_if_t<_Pred::value>...> __and_helper(int);
                               ^
/Applications/Xcode_15.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/__type_traits/conjunction.h:38:39: note: while substituting explicitly-specified template arguments into function template '__and_helper' 
using _And _LIBCPP_NODEBUG = decltype(std::__and_helper<_Pred...>(0));
                                      ^
/Applications/Xcode_15.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/__memory/pointer_traits.h:200:5: note: (skipping 4 contexts in backtrace; use -ftemplate-backtrace-limit=0 to see all)
    _And<is_class<_Pointer>, _IsFancyPointer<_Pointer> >::value
    ^
/Applications/Xcode_15.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/__iterator/concepts.h:193:7: note: in instantiation of requirement here
    { _VSTD::to_address(__i) } -> same_as<add_pointer_t<iter_reference_t<_Ip>>>;
      ^~~~~~~~~~~~~~~~~~~~~~
/Applications/Xcode_15.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/__config:897:17: note: expanded from macro '_VSTD'
#  define _VSTD std
                ^
/Applications/Xcode_15.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/__iterator/concepts.h:192:3: note: while substituting template arguments into constraint expression here
  requires(const _Ip& __i) {
  ^~~~~~~~~~~~~~~~~~~~~~~~~~
/Applications/Xcode_15.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/__ranges/concepts.h:122:5: note: while checking the satisfaction of concept 'contiguous_iterator<rust::Slice<const unsigned char>::iterator>' requested here
    contiguous_iterator<iterator_t<_Tp>> &&
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Applications/Xcode_15.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/__ranges/concepts.h:122:5: note: while substituting template arguments into constraint expression here
    contiguous_iterator<iterator_t<_Tp>> &&
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/runner/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/cxx-1.0.160/src/../include/cxx.h:282:15: note: while checking the satisfaction of concept 'contiguous_range<rust::Slice<const unsigned char>>' requested here
static_assert(std::ranges::contiguous_range<rust::Slice<const uint8_t>>);
              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Applications/Xcode_15.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/__memory/pointer_traits.h:38:8: note: template is declared here
struct __pointer_traits_element_type;
       ^
1 error generated.

error: failed to run custom build command for `cxx v1.0.160`
error occurred in cc-rs: command did not execute successfully (status code exit status: 1): env -u IPHONEOS_DEPLOYMENT_TARGET LC_ALL="C" "c++" "-O2" "-ffunction-sections" "-fdata-sections" "-fPIC" "-gdwarf-2" "-fno-omit-frame-pointer" "--target=arm64-apple-macosx" "-mmacosx-version-min=14.5" "-std=c++20" "-Wall" "-Wextra" "-o" "/Users/runner/work/miri/miri/target/debug/build/cxx-efb7933382949e42/out/c16f17691ff6f04b-cxx.o" "-c" "/Users/runner/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/cxx-1.0.160/src/cxx.cc"

Here is the full log from CI in case it's needed.

This failing CI run uses the exact same MacOS image (macos-14-arm64, Version: 20250630.1634) that was used in a successful cxx CI run a few hours ago. The most significant difference seems to be using C++20, since the failing static_assert only applies to this/higher versions. From what I can tell from this ci.yml, the combination of MacOS + C++20 isn't tested in cxx CI, which is likely why the problem didn't show up there.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions