[llvm-bugs] [Bug 40124] New: [regression] std::array<int, 0>::begin() should be constexpr but isn't
via llvm-bugs
llvm-bugs at lists.llvm.org
Thu Dec 20 13:49:49 PST 2018
https://bugs.llvm.org/show_bug.cgi?id=40124
Bug ID: 40124
Summary: [regression] std::array<int, 0>::begin() should be
constexpr but isn't
Product: libc++
Version: 7.0
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: All Bugs
Assignee: unassignedclangbugs at nondot.org
Reporter: tonyelewis at hotmail.com
CC: llvm-bugs at lists.llvm.org, mclow.lists at gmail.com
Compiling the following with `-fsyntax-only -std=c++17 -stdlib=libc++` :
~~~
#include <array>
template <typename Range>
inline constexpr bool f(const Range &prmRange) {
prmRange.begin();
return true;
}
void some_function() {
static_assert( f( ::std::array<int, 1>{ 0 } ) );
static_assert( f( ::std::array<int, 0>{ } ) );
}
~~~
I get:
~~~
a.cpp:11:17: error: static_assert expression is not an integral constant
expression
static_assert( f( ::std::array<int, 0>{ } ) );
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cpp:5:11: note: non-constexpr function 'begin' cannot be used in a constant
expression
prmRange.begin();
^
a.cpp:11:17: note: in call to 'f(::std::array<int, 0>{})'
static_assert( f( ::std::array<int, 0>{ } ) );
^
/home/lewis/source/llvm/bin/../include/c++/v1/array:273:20: note: declared here
const_iterator begin() const _NOEXCEPT {return const_iterator(data());}
^
1 error generated.
~~~
It looks like the zero-size specialisation of `::std::array` has some
constexprs missing. From what I can see in "26.3.7.1 Class template array
overview [array.overview]" and "26.3.7.8 Zero sized arrays [array.zero]" of the
C++17 draft, a zero-sized array should have constexpr `begin()` (etc).
This appears to be a regression: on Godbolt, I'm seeing this fail to compile in
this way under 7.0 and trunk, but compile cleanly under 6.0.
Thanks very much for all work on libc++.
--
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/20181220/fdd4aa6c/attachment.html>
More information about the llvm-bugs
mailing list