HomePhabricator

[libc++] span: Fix incorrect static asserts

Authored by ldionne on Feb 14 2020, 5:31 AM.

Description

[libc++] span: Fix incorrect static asserts

The static asserts in span<T, N>::front() and span<T, N>::back() are
incorrect as they may be triggered from valid code due to evaluation
of a never taken branch:

span<int, 0> foo;
if (!foo.empty()) {
    auto x = foo.front();
}

The problem is that the branch is always evaluated by the compiler,
creating invalid compile errors for span<T, 0>.

Thanks to Michael Schellenberger Costa for the patch.

Differential Revision: https://reviews.llvm.org/D71995

Details

Committed
ldionneFeb 14 2020, 5:32 AM
Differential Revision
D71995: [libcxx] span: Fix incorrect static asserts
Parents
rG84240e0db8ab: [clang][Index] Introduce a TemplateParm SymbolKind
Branches
Unknown
Tags
Unknown