<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 - [span] Incorrect static_assert in span::front and span::back"
   href="https://bugs.llvm.org/show_bug.cgi?id=44725">44725</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[span] Incorrect static_assert in span::front and span::back
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libc++
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>10.0
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

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

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>All Bugs
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>mschellenbergercosta@googlemail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org, mclow.lists@gmail.com
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Currently ```span<T, extent>::front()``` and ```span<T, extent>::back()``` have
a static_assert that checks whether ```extent > 0```.

However, this is an invalid requirement, as it would trigger in all evaluated
branches. Consider the following code

```
template<class R>
int get_front_or_default(R myRange, int myDefault) {
    if (!myRange.empty()) 
       return myRange.front();
    else
       return myDefault; 
}
```

This would give a compile error when passed a span<int, 0> albeit the front()
method is never called. Consequently, the static_assert should be replaced by
an _LIBCPP_ASSERT.


There is already a PR for that (<a href="https://reviews.llvm.org/D71995">https://reviews.llvm.org/D71995</a>)</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>