<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Needless instantiation in requires-expression"
   href="https://bugs.llvm.org/show_bug.cgi?id=49657">49657</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Needless instantiation in requires-expression
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>URL</th>
          <td>https://godbolt.org/z/3q4frc
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Keywords</th>
          <td>compile-fail
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>C++2a
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>johelegp@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>blitzrakete@gmail.com, erik.pilkington@gmail.com, johelegp@gmail.com, llvm-bugs@lists.llvm.org, richard-llvm@metafoo.co.uk
          </td>
        </tr></table>
      <p>
        <div>
        <pre>See <a href="https://godbolt.org/z/3q4frc">https://godbolt.org/z/3q4frc</a>.
```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
```</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>