https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124057

            Bug ID: 124057
           Summary: GCC still rejects C++26 contexpr std::span using
                    std::initializer_list
           Product: gcc
           Version: 16.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jlame646 at gmail dot com
  Target Milestone: ---

The following program should be accepted by gcc using P2447 but gcc trunk still
rejects it:
```
#include <span>
#include<initializer_list>
int main(int argc, char **argv) {
     constexpr std::span<const int> s = {0,0};//should be accepted as of c++26
p2447
}
```
But gcc incorrectly rejects it:
```
<source>: In function 'int main(int, char**)':
<source>:4:45: error: 'std::span<const int>{((const int*)(&<anonymous>)),
std::__detail::__extent_storage<18446744073709551615>{2}}' is not a constant
expression
    4 |      constexpr std::span<const int> s = {0,0};//should be accepted as
of c++26 p2447
      |                                             ^
<source>:4:45: error: 'std::span<const int>(std::initializer_list<int>{((const
int*)(& const int [2]{0, 0})), 2})' is not a constant expression because it
refers to an incompletely initialized variable
Compiler returned: 1
```

Note that other compiler also rejects it.

Reply via email to