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