[llvm-bugs] [Bug 49657] New: Needless instantiation in requires-expression
via llvm-bugs
llvm-bugs at lists.llvm.org
Fri Mar 19 21:50:14 PDT 2021
https://bugs.llvm.org/show_bug.cgi?id=49657
Bug ID: 49657
Summary: Needless instantiation in requires-expression
Product: clang
Version: trunk
Hardware: PC
URL: https://godbolt.org/z/3q4frc
OS: Linux
Status: NEW
Keywords: compile-fail
Severity: enhancement
Priority: P
Component: C++2a
Assignee: unassignedclangbugs at nondot.org
Reporter: johelegp at gmail.com
CC: blitzrakete at gmail.com, erik.pilkington at gmail.com,
johelegp at gmail.com, llvm-bugs at lists.llvm.org,
richard-llvm at metafoo.co.uk
See https://godbolt.org/z/3q4frc.
```C++
#include<span>
struct X;
struct Y { std::span<Y> s; };
Y y{};
Y y2 = y;
```
When generating the copy constructor for `Y`, candidate
`span::span(contiguous_range auto&& r)` checks for `ranges::end(r)`. `r.end()`
ends up being instantiated, even though there's nothing in the immediate
context that requires instantiating it.
```
In file included from <source>:1:
/opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/11.0.1/../../../../include/c++/11.0.1/span:292:38:
error: arithmetic on a pointer to an incomplete type 'Y'
{ return iterator(this->_M_ptr + this->size()); }
~~~~~~~~~~~~ ^
/opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/11.0.1/../../../../include/c++/11.0.1/bits/ranges_base.h:179:17:
note: in instantiation of member function 'std::span<Y,
18446744073709551615>::end' requested here
return __t.end();
^
/opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/11.0.1/../../../../include/c++/11.0.1/bits/ranges_base.h:582:2:
note: in instantiation of function template specialization
'std::ranges::__cust_access::_End::operator()<const std::span<Y,
18446744073709551615> &>' requested here
ranges::end(__t);
^
/opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/11.0.1/../../../../include/c++/11.0.1/bits/ranges_base.h:582:2:
note: in instantiation of requirement here
ranges::end(__t);
^~~~~~~~~~~~~~~~
/opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/11.0.1/../../../../include/c++/11.0.1/bits/ranges_base.h:579:21:
note: while substituting template arguments into constraint expression here
concept range = requires(_Tp& __t)
^~~~~~~~~~~~~~~~~~
/opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/11.0.1/../../../../include/c++/11.0.1/bits/ranges_base.h:639:27:
note: while checking the satisfaction of concept 'range<const std::span<Y,
18446744073709551615> &>' requested here
concept input_range = range<_Tp> && input_iterator<iterator_t<_Tp>>;
^~~~~~~~~~
/opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/11.0.1/../../../../include/c++/11.0.1/bits/ranges_base.h:639:27:
note: (skipping 9 contexts in backtrace; use -ftemplate-backtrace-limit=0 to
see all)
/opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/11.0.1/../../../../include/c++/11.0.1/span:202:11:
note: while checking the satisfaction of concept 'contiguous_range<const
std::span<Y, 18446744073709551615> &>' requested here
requires ranges::contiguous_range<_Range> &&
ranges::sized_range<_Range>
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/11.0.1/../../../../include/c++/11.0.1/span:202:19:
note: while substituting template arguments into constraint expression here
requires ranges::contiguous_range<_Range> &&
ranges::sized_range<_Range>
^~~~~~~~~~~~~~~~~~~~~~~~
/opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/11.0.1/../../../../include/c++/11.0.1/span:104:11:
note: while checking constraint satisfaction for template 'span<const
std::span<Y, 18446744073709551615> &>' required here
class span
^~~~
/opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/11.0.1/../../../../include/c++/11.0.1/span:104:11:
note: in instantiation of function template specialization 'std::span<Y,
18446744073709551615>::span<const std::span<Y, 18446744073709551615> &>'
requested here
<source>:3:8: note: while declaring the implicit copy constructor for 'Y'
struct Y { std::span<Y> s; };
^
<source>:3:8: note: definition of 'Y' is not complete until the closing '}'
1 error generated.
Compiler returned: 1
```
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20210320/b443a4c1/attachment-0001.html>
More information about the llvm-bugs
mailing list