https://bugs.llvm.org/show_bug.cgi?id=44725
Bug ID: 44725
Summary: [span] Incorrect static_assert in span::front and
span::back
Product: libc++
Version: 10.0
Hardware: All
OS: All
Status: NEW
Severity: normal
Priority: P
Component: All Bugs
Assignee: [email protected]
Reporter: [email protected]
CC: [email protected], [email protected]
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 (https://reviews.llvm.org/D71995)
--
You are receiving this mail because:
You are on the CC list for the bug._______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs