<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/85553>85553</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            `std::vector<bool>` cannot be used in a constexpr context with `stdlibc++`
        </td>
    </tr>

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

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          rHermes
      </td>
    </tr>
</table>

<pre>
    Code to reproduce:

```cpp
#include<vector>
consteval int foo(){
 std::vector<bool>seen(26);
    return 0;
}
int main(){
 return foo();
}
```

When compiling with:

```
clang++ -std=c++2a lel.cpp
```

I get the following error message:

```
lel.cpp:7:12: error: call to consteval function 'foo' is not a constant expression
    return foo();
 ^
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/13.2.1/../../../../include/c++/13.2.1/bits/stl_bvector.h:649:15: note: assignment to object outside its lifetime is not allowed in a constant expression
            __p[__i] = 0ul;
 ^
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/13.2.1/../../../../include/c++/13.2.1/bits/stl_bvector.h:1317:31: note: in call to '&seen->_M_allocate(1)'
            _Bit_pointer __q = this->_M_allocate(__n);
 ^
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/13.2.1/../../../../include/c++/13.2.1/bits/stl_bvector.h:768:2: note: in call to '&seen->_M_initialize(26)'
 _M_initialize(__n);
 ^
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/13.2.1/../../../../include/c++/13.2.1/bits/stl_bvector.h:755:9: note: in call to 'vector(26, false, allocator_type())'
      : vector(__n, false, __a)
        ^
lel.cpp:3:22: note: in call to 'vector(26, allocator_type())'
    std::vector<bool>seen(26);
 ^
lel.cpp:7:12: note: in call to 'foo()'
    return foo();
 ^
1 error generated.
```

But when I do it with `libc++`, there is no error:

```
clang++ -std=c++2a lel.cpp -stdlib=libc++
```

Works just fine. GCC handles compiling just fine with `stdlibc++`.

Here are the clang specs:

```
clang version 16.0.6
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
```

And gcc version:
```
g++ (GCC) 13.2.1 20230801
```


</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzUVs1yozgQfhr50mVKSAbsAwf_xDNz2NtW7ZES0AbNyhIriSSzT78lMNhJnGy29jKTSmGButXdX_98Es7JRiPmJNmR5LAQvW-Nze1XtGd0i9LUP_K9qRG8AYudNXVfIeFbQg-ETs-Ujv9V112-MC51pfoaCd8_YuWNJfxh3KuMdh4fhQKpPZyMIWxN2IZku3EfnK-DAb6dFPelMYrwB4eoCVuzNIjzSRwALPreaqDzR5IdxkUwcRZSv7Zx0bhaf6M5B3Ub6R8taqjMuZNK6gaepG_fw-ISrBK6IWxH2A6WQ2CHanxlAhSq6ArZPXvfoEEPvkU4GaXMUzCK1hoLZ3RONO9mYnydDPBtRvg2ZoRvR_WwqIRSIavXfJx6XXlpNBCWDchkIB1o40GMUkJ7wOfOonPS6Df4v0UTSPIwVcSxd5awYxmScYwiwo5KlumKsGNTVYQdn9dpka6WXbVUUvfPy0b3hB1jHrEonjRePaYaY8cLqLcKpfSOsKPzqijHSopCstLVJmCRBAi08QFBGJvgjNoHQEz5HSsPpvdO1gjSO1DyhF6eccYjJANrkPrfoJn-iqIjya4oJEkOQPgBaK9-ZphiHoea4fEtTlLPVUNYRlgaOnJJ-EPxWxEgqYRHwtZxKAGW3QFhJ33RGak9WiiKvwYgfCvd2zOKQv_khZSla8K37LP4SC29FEr-jfMImyF6vf0LBJ-EBtq8H_xldo-h7uEklMOwuKTY2ML_6PAyLt6USzhvPmFA4-aIohBB40V1zQhdRx4P2fkgPa88_Ixj_5GZ7jh1ncP3nbqO0Fu7n5iv8YUXGtRohcc6-oBWdr2Hp0Bl36A2IP1AZEBSqmQ51UBKAyq-RXuZejNz_E-6GzaULAk_3Jj7gHON_dPB9955OEmNEXzZ76EVulbobrh4Fpi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