<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 - [regression] std::array<int, 0>::begin() should be constexpr but isn't"
   href="https://bugs.llvm.org/show_bug.cgi?id=40124">40124</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[regression] std::array<int, 0>::begin() should be constexpr but isn't
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>7.0
          </td>
        </tr>

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

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

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

        <tr>
          <th>Severity</th>
          <td>enhancement
          </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>tonyelewis@hotmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org, mclow.lists@gmail.com
          </td>
        </tr></table>
      <p>
        <div>
        <pre>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++.</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>