Skip to content

[Bug] - clang++ 15.0.7 in C++20 mode with stdlibc++ 14 fails with <chrono> on AL 2023.7.20250331 #943

Open
@JoachimSchurig

Description

@JoachimSchurig

Using clang++ and including <chrono> on AL 2023.7.20250331 in C++20 mode breaks the iterator implementation in libstdc++ 14.

To Reproduce
This code

#include <chrono>

int main()
{
	return 0;
}

when being compiled with clang++ -std=c++20 test.cpp -o test results in several pages of template errors, with these first lines:

In file included from test.cpp:1:
In file included from /usr/bin/../lib/gcc/aarch64-amazon-linux/14/../../../../include/c++/14/chrono:45:
In file included from /usr/bin/../lib/gcc/aarch64-amazon-linux/14/../../../../include/c++/14/sstream:40:
In file included from /usr/bin/../lib/gcc/aarch64-amazon-linux/14/../../../../include/c++/14/istream:40:
In file included from /usr/bin/../lib/gcc/aarch64-amazon-linux/14/../../../../include/c++/14/ios:42:
In file included from /usr/bin/../lib/gcc/aarch64-amazon-linux/14/../../../../include/c++/14/bits/char_traits.h:57:
In file included from /usr/bin/../lib/gcc/aarch64-amazon-linux/14/../../../../include/c++/14/bits/stl_construct.h:61:
In file included from /usr/bin/../lib/gcc/aarch64-amazon-linux/14/../../../../include/c++/14/bits/stl_iterator_base_types.h:71:
/usr/bin/../lib/gcc/aarch64-amazon-linux/14/../../../../include/c++/14/bits/iterator_concepts.h:1037:13: error: no matching function for call to '__begin'
        = decltype(ranges::__access::__begin(std::declval<_Tp&>()));
                   ^~~~~~~~~~~~~~~~~~~~~~~~~
/usr/bin/../lib/gcc/aarch64-amazon-linux/14/../../../../include/c++/14/bits/ranges_base.h:511:5: note: in instantiation of template type alias '__range_iter_t' requested here
    using iterator_t = std::__detail::__range_iter_t<_Tp>;
    ^
/usr/bin/../lib/gcc/aarch64-amazon-linux/14/../../../../include/c++/14/bits/ranges_util.h:132:36: note: in instantiation of template type alias 'iterator_t' requested here
      requires contiguous_iterator<iterator_t<_Derived>>
                                   ^
/usr/bin/../lib/gcc/aarch64-amazon-linux/14/../../../../include/c++/14/bits/ranges_util.h:262:29: note: in instantiation of template class 'std::ranges::view_interface<std::ranges::subrange<const wchar_t *, const wchar_t *, std::ranges::subrange_kind::sized>>' requested here
    class subrange : public view_interface<subrange<_It, _Sent, _Kind>>
                            ^
/usr/bin/../lib/gcc/aarch64-amazon-linux/14/../../../../include/c++/14/bits/iterator_concepts.h:1003:22: note: in instantiation of template class 'std::ranges::subrange<const wchar_t *, const wchar_t *, std::ranges::subrange_kind::sized>' requested here
          { __decay_copy(__t.begin()) } -> input_or_output_iterator;
                            ^
/usr/bin/../lib/gcc/aarch64-amazon-linux/14/../../../../include/c++/14/bits/iterator_concepts.h:1003:6: note: in instantiation of requirement here
          { __decay_copy(__t.begin()) } -> input_or_output_iterator;
            ^~~~~~~~~~~~~~~~~~~~~~~~~
/usr/bin/../lib/gcc/aarch64-amazon-linux/14/../../../../include/c++/14/bits/iterator_concepts.h:1001:32: note: (skipping 11 contexts in backtrace; use -ftemplate-backtrace-limit=0 to see all)
      concept __member_begin = requires(_Tp& __t)
                               ^
/usr/bin/../lib/gcc/aarch64-amazon-linux/14/../../../../include/c++/14/bits/unicode.h:591:5: note: while checking constraint satisfaction for template '_Utf_view<char32_t, std::ranges::subrange<const wchar_t *, const wchar_t *, std::ranges::subrange_kind::sized>>' required here
    using _Utf32_view = _Utf_view<char32_t, _View>;
    ^~~~~
/usr/bin/../lib/gcc/aarch64-amazon-linux/14/../../../../include/c++/14/format:439:3: note: in instantiation of template type alias '_Utf32_view' requested here
                _Utf32_view<ranges::subrange<iterator>> __uv({__first, __last});
                ^

It compiles fine with gcc14-g++ -std=c++20 test.cpp -o test.

Expected behavior
No error.

Note
This ticket was initially about including the <format> header, but I demonstrate this now with including the <chrono> header - as that one existed long before C++20.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions