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

    <tr>
        <th>Summary</th>
        <td>
            [libc++] `std::vector<char[16]>` error: cannot initialize return object of type `char *[16]` with an rvalue of type `char *`
        </td>
    </tr>

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

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

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

<pre>
    According to https://stackoverflow.com/a/63259370/337979, the following code should work since c++11:

```c++
#include <vector>

void test(){
        std::vector<char[16]> alpha(10);
        static_assert(sizeof(alpha[0]) == 16, "Size of each element in alpha is not 16 bytes");
}
```

It works with libstdc++ (both in gcc/clang), but fails with libc++

```
$ clang++ -std=c++23 --stdlib=libstdc++ main.cpp -c -o main.o
# ok!

$ clang++ -std=c++23 --stdlib=libc++ main.cpp -c -o main.o
In file included from main.cpp:1:
In file included from /usr/include/c++/v1/vector:308:
In file included from /usr/include/c++/v1/__algorithm/copy.h:12:
In file included from /usr/include/c++/v1/__algorithm/copy_move_common.h:18:
In file included from /usr/include/c++/v1/__string/constexpr_c_functions.h:14:
/usr/include/c++/v1/__memory/construct_at.h:41:10: error: cannot initialize return object of type 'char *[16]' with an rvalue of type
      'char *'
   41 |   return ::new (std::__voidify(*__location)) _Tp(std::forward<_Args>(__args)...);
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/v1/__memory/construct_at.h:49:15: note: in instantiation of function template specialization
 'std::construct_at<char[16], char *>' requested here
   49 |   return std::construct_at(__location, std::forward<_Args>(__args)...);
      | ^
/usr/include/c++/v1/__memory/allocator_traits.h:305:10: note: in instantiation of function template specialization
 'std::__construct_at<char[16], char *>' requested here
  305 | std::__construct_at(__p, std::forward<_Args>(__args)...);
      | ^
/usr/include/c++/v1/vector:1057:21: note: in instantiation of function template specialization
 'std::allocator_traits<std::allocator<char[16]>>::construct<char[16], void, void>' requested here
 1057 | __alloc_traits::construct(this->__alloc(), std::__to_address(__pos));
 |                     ^
/usr/include/c++/v1/vector:1122:5: note: in instantiation of member function 'std::vector<char[16]>::__construct_at_end' requested here
 1122 |     __construct_at_end(__n);
      | ^
main.cpp:4:24: note: in instantiation of member function 'std::vector<char[16]>::vector' requested here
    4 | std::vector<char[16]> alpha(10);
      | ^
1 error generated.
```

It looks similar to https://github.com/llvm/llvm-project/issues/40629, but probably different as `char[16]` is trivially destructible.

Checked with `clang version 18.1.8+libcxx` and `libcxx-18.1.8`. Discovered in https://github.com/ROCm/hipBLASLt/blob/f192cdec31dbdca581c8df03c3980b9cc5b678c7/library/src/amd_detail/rocblaslt/src/rocblaslt_mat.cpp#L605
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy8V01v4zgP_jXKRWggU_HXIYc0aYABCrzAO3s3ZImOtZWtrKSkkznsb1_Izue0nY9uZ4MgbmWRFJ-HpEjhvd70iHOS3pN0NRG70Fo3X_Qbd3i0T3pSW3WYL6S0Tul-Q4OlbQhbT_iCwJrA2gchn-weXWPs81TajsBaEFhnHNKS54zAmvO8zEsCSxpapI01xj5HXdIqpL61O6Pos3VP1OteIpUE7gncJ0m0wVaEnX4zNn6PG46rwHUvzU4hJXy5RxmsI_zhWnBvtaIBfSBQEChJfhJlpQ8qWuGLk-BStsKR9D7JSLoi_IEKs20FgSJhUZRfi4qgZSW8Rxc1e_0VbUOgGCXSexY1QEkJXxG-okkWESAAn_VXpLahKGRL0WCHfaC6Hy1R7WlvA00yWh8CegJwYzdffQPGtaOfwoCjp886tNTo2gd1BIsSKGob2mhoIyWBtTSi30TdsKT1LtBGaHORvMX4VZMwo0cdg4G7AcvVURA4vYsrRteEr26P0gndT-V2S-8kvbPjv_bMJrVPBJIbw79m6SfMfOppow3SY-Qo2jjbnQUIX1xi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