Bug#1001107: clang-13: clang++-13 has broken std::ranges::ref_view - iterator_concepts.h:980:13: error: no matching function for call to '__begin'
Daniel Boles
dboles.src at gmail.com
Sat Dec 4 13:10:28 GMT 2021
Package: clang-13
Version: 1:13.0.0-9+b1
Severity: important
Tags: upstream
Dear Maintainer,
clang++ 13, as of now in Debian unstable, and on Compiler Explorer,
causes
confusing and seemingly wrong template/constraint errors when trying to
compile
many pieces of code using std::ranges / std::views objects like
views::transform, seemingly because they end up using
std::ranges::ref_view and
that is broken.
I have encountered this when trying to build my own projects with
clang++
instead of my usual g++.
I can replicate it here on Compiler Explorer - using the example code
from
https://en.cppreference.com/w/cpp/ranges/transform_view - with clang++-
13 using
-std=c++20:
https://godbolt.org/z/f14zWMdWa
I cannot find any bug report for this upstream or on reportbug. I also
cannot
see how to report bugs to clang++ since its Bugzilla says it's in read-
only
mode due to migrating to GitHub, but its link to the status of the
migration
says it's been paused...
Thus can you please ensure this reaches the clang++ maintainers and is
patched
upstream and in Debian as soon as possible? Thanks!
Daniel
--
code:
--
#include <algorithm>
#include <array>
#include <cstdio>
#include <ranges>
#include <string>
class Transcoder {
static constexpr std::array r{
0x02,-0x02,-0x42, 0x05, 0x04, 0x05, 0x04,-0x02,
0x00,-0x0a, 0x06,-0x04, 0x00, 0x0c, 0x03,-0x06,
};
decltype(r.size()) p{}, q{};
public:
char operator() (int x) {
! (p|q)
? (99 == x ? x += r[p++] : x -= r[q++])
: (0 < p && p < r.size()) ? x += r[p++]
: (0 < q && q < r.size()) ? x -= r[q++]
: (0)
;
return x;
}
};
int main()
{
auto show = [](const char x) { std::putchar(x); };
std::string in{ "cppreference.com\n" };
std::ranges::for_each(in, show);
std::string out;
std::ranges::copy(
std::ranges::views::transform(in, Transcoder{}),
std::back_inserter(out));
std::ranges::for_each(out, show);
auto view = std::ranges::transform_view{ out, Transcoder{} };
std::ranges::for_each(view, show);
std::ranges::for_each(view, show);
}
--
errors:
--
/opt/compiler-explorer/gcc-11.2.0/lib/gcc/x86_64-linux-
gnu/11.2.0/../../../../include/c++/11.2.0/bits/iterator_concepts.h:962:
35:
note: and 'const std::ranges::ref_view<std::basic_string<char>> &' does
not
satisfy '__member_begin'
requires is_array_v<_Tp> || __member_begin<_Tp&> ||
__adl_begin<_Tp&>
^
/opt/compiler-explorer/gcc-11.2.0/lib/gcc/x86_64-linux-
gnu/11.2.0/../../../../include/c++/11.2.0/bits/iterator_concepts.h:945:
23:
note: because '__decay_copy(__t.begin())' would be invalid: no member
named
'begin' in 'std::ranges::ref_view<std::basic_string<char>>'
{ __decay_copy(__t.begin()) } -> input_or_output_iterator;
^
/opt/compiler-explorer/gcc-11.2.0/lib/gcc/x86_64-linux-
gnu/11.2.0/../../../../include/c++/11.2.0/bits/iterator_concepts.h:962:
59:
note: and 'const std::ranges::ref_view<std::basic_string<char>> &' does
not
satisfy '__adl_begin'
requires is_array_v<_Tp> || __member_begin<_Tp&> ||
__adl_begin<_Tp&>
^
/opt/compiler-explorer/gcc-11.2.0/lib/gcc/x86_64-linux-
gnu/11.2.0/../../../../include/c++/11.2.0/bits/iterator_concepts.h:956:
19:
note: because '__decay_copy(begin(__t))' would be invalid: call to
deleted
function 'begin'
{ __decay_copy(begin(__t)) } -> input_or_output_iterator;
^
In file included from <source>:1:
In file included from /opt/compiler-explorer/gcc-11.2.0/lib/gcc/x86_64-
linux-
gnu/11.2.0/../../../../include/c++/11.2.0/algorithm:64:
In file included from /opt/compiler-explorer/gcc-11.2.0/lib/gcc/x86_64-
linux-
gnu/11.2.0/../../../../include/c++/11.2.0/bits/ranges_algo.h:36:
/opt/compiler-explorer/gcc-11.2.0/lib/gcc/x86_64-linux-
gnu/11.2.0/../../../../include/c++/11.2.0/bits/ranges_util.h:110:24:
error:
constraints not satisfied for alias template 'sentinel_t' [with _Range
=
std::ranges::ref_view<std::basic_string<char>>]
&& sized_sentinel_for<sentinel_t<_Derived>,
iterator_t<_Derived>>
^~~~~~~~~~~~~~~~~~~~
/opt/compiler-explorer/gcc-11.2.0/lib/gcc/x86_64-linux-
gnu/11.2.0/../../../../include/c++/11.2.0/ranges:1013:29: note: in
instantiation of template class
'std::ranges::view_interface<std::ranges::ref_view<std::basic_string<ch
ar>>>'
requested here
class ref_view : public view_interface<ref_view<_Range>>
^
/opt/compiler-explorer/gcc-11.2.0/lib/gcc/x86_64-linux-
gnu/11.2.0/../../../../include/c++/11.2.0/ranges:1069:38: note: in
instantiation of template class
'std::ranges::ref_view<std::basic_string<char>>' requested here
concept __can_ref_view = requires {
ref_view{std::declval<_Range>()};
};
^
/opt/compiler-explorer/gcc-11.2.0/lib/gcc/x86_64-linux-
gnu/11.2.0/../../../../include/c++/11.2.0/ranges:1069:38: note: in
instantiation of requirement here
concept __can_ref_view = requires {
ref_view{std::declval<_Range>()};
};
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/opt/compiler-explorer/gcc-11.2.0/lib/gcc/x86_64-linux-
gnu/11.2.0/../../../../include/c++/11.2.0/ranges:1069:27: note: while
substituting template arguments into constraint expression here
concept __can_ref_view = requires {
ref_view{std::declval<_Range>()};
};
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/opt/compiler-explorer/gcc-11.2.0/lib/gcc/x86_64-linux-
gnu/11.2.0/../../../../include/c++/11.2.0/ranges:1079:7: note: while
checking
the satisfaction of concept '__can_ref_view<std::basic_string<char> &>'
requested here
|| __detail::__can_ref_view<_Range>
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/opt/compiler-explorer/gcc-11.2.0/lib/gcc/x86_64-linux-
gnu/11.2.0/../../../../include/c++/11.2.0/ranges:1079:17: note:
(skipping 6
contexts in backtrace; use -ftemplate-backtrace-limit=0 to see all)
|| __detail::__can_ref_view<_Range>
^
/opt/compiler-explorer/gcc-11.2.0/lib/gcc/x86_64-linux-
gnu/11.2.0/../../../../include/c++/11.2.0/ranges:1906:6: note: while
substituting template arguments into constraint expression here
= requires { transform_view(std::declval<_Range>(),
std::declval<_Fp>()); };
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~
/opt/compiler-explorer/gcc-11.2.0/lib/gcc/x86_64-linux-
gnu/11.2.0/../../../../include/c++/11.2.0/ranges:1912:11: note: while
checking
the satisfaction of concept
'__can_transform_view<std::basic_string<char> &,
Transcoder>' requested here
requires __detail::__can_transform_view<_Range, _Fp>
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/opt/compiler-explorer/gcc-11.2.0/lib/gcc/x86_64-linux-
gnu/11.2.0/../../../../include/c++/11.2.0/ranges:1912:21: note: while
substituting template arguments into constraint expression here
requires __detail::__can_transform_view<_Range, _Fp>
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<source>:34:38: note: while checking constraint satisfaction for
template
'operator()<std::basic_string<char> &, Transcoder>' required here
std::ranges::views::transform(in, Transcoder{}),
^
<source>:34:38: note: in instantiation of function template
specialization
'std::ranges::views::_Transform::operator()<std::basic_string<char> &,
Transcoder>' requested here
/opt/compiler-explorer/gcc-11.2.0/lib/gcc/x86_64-linux-
gnu/11.2.0/../../../../include/c++/11.2.0/bits/ranges_base.h:588:12:
note:
because 'std::ranges::ref_view<std::basic_string<char>>' does not
satisfy
'range'
template<range _Range>
^
/opt/compiler-explorer/gcc-11.2.0/lib/gcc/x86_64-linux-
gnu/11.2.0/../../../../include/c++/11.2.0/bits/ranges_base.h:576:2:
note:
because 'ranges::begin(__t)' would be invalid: no matching function for
call to
object of type 'const __cust_access::_Begin'
ranges::begin(__t);
^
In file included from <source>:1:
In file included from /opt/compiler-explorer/gcc-11.2.0/lib/gcc/x86_64-
linux-
gnu/11.2.0/../../../../include/c++/11.2.0/algorithm:64:
In file included from /opt/compiler-explorer/gcc-11.2.0/lib/gcc/x86_64-
linux-
gnu/11.2.0/../../../../include/c++/11.2.0/bits/ranges_algo.h:36:
/opt/compiler-explorer/gcc-11.2.0/lib/gcc/x86_64-linux-
gnu/11.2.0/../../../../include/c++/11.2.0/bits/ranges_util.h:116:24:
error:
constraints not satisfied for alias template 'sentinel_t' [with _Range
= const
std::ranges::ref_view<std::basic_string<char>>]
&& sized_sentinel_for<sentinel_t<const _Derived>,
^~~~~~~~~~~~~~~~~~~~~~~~~~
/opt/compiler-explorer/gcc-11.2.0/lib/gcc/x86_64-linux-
gnu/11.2.0/../../../../include/c++/11.2.0/bits/ranges_base.h:588:12:
note:
because 'const std::ranges::ref_view<std::basic_string<char>>' does not
satisfy
'range'
template<range _Range>
^
/opt/compiler-explorer/gcc-11.2.0/lib/gcc/x86_64-linux-
gnu/11.2.0/../../../../include/c++/11.2.0/bits/ranges_base.h:576:2:
note:
because 'ranges::begin(__t)' would be invalid: no matching function for
call to
object of type 'const __cust_access::_Begin'
ranges::begin(__t);
^
<source>:34:9: error: no matching function for call to object of type
'const
std::ranges::views::_Transform'
std::ranges::views::transform(in, Transcoder{}),
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/opt/compiler-explorer/gcc-11.2.0/lib/gcc/x86_64-linux-
gnu/11.2.0/../../../../include/c++/11.2.0/ranges:1914:2: note:
candidate
template ignored: constraints not satisfied [with _Range =
std::basic_string<char> &, _Fp = Transcoder]
operator()(_Range&& __r, _Fp&& __f) const
^
/opt/compiler-explorer/gcc-11.2.0/lib/gcc/x86_64-linux-
gnu/11.2.0/../../../../include/c++/11.2.0/ranges:1912:21: note: because
'__detail::__can_transform_view<std::basic_string<char> &, Transcoder>'
evaluated to false
requires __detail::__can_transform_view<_Range, _Fp>
^
/opt/compiler-explorer/gcc-11.2.0/lib/gcc/x86_64-linux-
gnu/11.2.0/../../../../include/c++/11.2.0/ranges:1906:17: note: because
'transform_view(std::declval<_Range>(), std::declval<_Fp>())' would be
invalid:
no viable constructor or deduction guide for deduction of template
arguments of
'transform_view'
= requires { transform_view(std::declval<_Range>(),
std::declval<_Fp>()); };
^
/opt/compiler-explorer/gcc-11.2.0/lib/gcc/x86_64-linux-
gnu/11.2.0/../../../../include/c++/11.2.0/ranges:806:2: note: candidate
template ignored: constraints not satisfied [with _Args =
<std::basic_string<char> &, Transcoder>]
operator()(_Args&&... __args) const
^
/opt/compiler-explorer/gcc-11.2.0/lib/gcc/x86_64-linux-
gnu/11.2.0/../../../../include/c++/11.2.0/ranges:804:11: note: because
'__adaptor_partial_app_viable<std::ranges::views::_Transform,
std::basic_string<char> &, Transcoder>' evaluated to false
requires __adaptor_partial_app_viable<_Derived, _Args...>
^
/opt/compiler-explorer/gcc-11.2.0/lib/gcc/x86_64-linux-
gnu/11.2.0/../../../../include/c++/11.2.0/ranges:753:11: note: because
'sizeof...(_Args) == _Transform::_S_arity - 1' (2 == 1) evaluated to
false
&& (sizeof...(_Args) == _Adaptor::_S_arity - 1)
^
<source>:38:17: error: no viable constructor or deduction guide for
deduction
of template arguments of 'transform_view'
auto view = std::ranges::transform_view{ out, Transcoder{} };
^
/opt/compiler-explorer/gcc-11.2.0/lib/gcc/x86_64-linux-
gnu/11.2.0/../../../../include/c++/11.2.0/ranges:1846:7: note:
candidate
template ignored: substitution failure [with _Vp =
std::basic_string<char>, _Fp
= Transcoder]: constraints not satisfied for class template
'transform_view'
[with _Vp = std::basic_string<char>, _Fp = Transcoder]
transform_view(_Vp __base, _Fp __fun)
^
/opt/compiler-explorer/gcc-11.2.0/lib/gcc/x86_64-linux-
gnu/11.2.0/../../../../include/c++/11.2.0/ranges:1898:5: note:
candidate
template ignored: substitution failure [with _Range =
std::basic_string<char>
&, _Fp = Transcoder]: constraints not satisfied for class template
'transform_view' [with _Vp =
std::ranges::ref_view<std::basic_string<char>>,
_Fp = Transcoder]
transform_view(_Range&&, _Fp) ->
transform_view<views::all_t<_Range>, _Fp>;
^ ~~~~~~~~~~~~~~
/opt/compiler-explorer/gcc-11.2.0/lib/gcc/x86_64-linux-
gnu/11.2.0/../../../../include/c++/11.2.0/ranges:1557:11: note:
candidate
function template not viable: requires 1 argument, but 2 were provided
class transform_view : public view_interface<transform_view<_Vp,
_Fp>>
^
/opt/compiler-explorer/gcc-11.2.0/lib/gcc/x86_64-linux-
gnu/11.2.0/../../../../include/c++/11.2.0/ranges:1843:7: note:
candidate
function template not viable: requires 0 arguments, but 2 were provided
transform_view() = default;
^
6 errors generated.
Compiler returned: 1
-- System Information:
Debian Release: bookworm/sid
APT prefers unstable
APT policy: (500, 'unstable'), (500, 'testing'), (1, 'experimental')
Architecture: amd64 (x86_64)
Foreign Architectures: i386
Kernel: Linux 5.15.0-2-amd64 (SMP w/8 CPU threads)
Kernel taint flags: TAINT_OOT_MODULE, TAINT_UNSIGNED_MODULE
Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8),
LANGUAGE not set
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled
Versions of packages clang-13 depends on:
ii binutils 2.37-10
ii libc6 2.32-4
ii libc6-dev 2.32-4
ii libclang-common-13-dev 1:13.0.0-9+b1
ii libclang-cpp13 1:13.0.0-9+b1
ii libclang1-13 1:13.0.0-9+b1
ii libgcc-11-dev 11.2.0-12
ii libgcc-s1 11.2.0-12
ii libllvm13 1:13.0.0-9+b1
ii libobjc-11-dev 11.2.0-12
ii libstdc++-11-dev 11.2.0-12
ii libstdc++6 11.2.0-12
Versions of packages clang-13 recommends:
ii llvm-13-dev 1:13.0.0-9+b1
ii python3 3.9.8-1
Versions of packages clang-13 suggests:
pn clang-13-doc <none>
-- no debconf information
More information about the Pkg-llvm-team
mailing list