May 16th 2020
Also speaking of copyable arrays, for anyone who hasn't seen it yet,
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95153std::is_copy_constructible<bool[2]>andstd::is_copy_constructible<const void*[2]>are bothtruein C++20 because of aggregate-initialization-via-parentheses.bool a[2]; bool b[2](a);is valid C++20.
On Sun, Aug 1, 2021 at 2:56 PM Uecker, Martin via Liaison <liaison@lists.isocpp.org> wrote:Would the following example change behavior?
void foo(void)
{
void* b[3];
void* a[1][3] = { b };
}Yes - I guess so.Is the initialization of 'a' ill-formed in C++? g++ rejects it with:error: array must be initialized with a brace-enclosed initializer4 | const void* a[1][3] = { b };| ^ (it's accepted by clang++ and msvc, though, in pedantic/non-permissive mode) (on adding another brace it is accepted by all 3).There's a similar case with array-of-bool: #include <stdbool.h>void foo(void){bool b[3];bool a[2][3] = { b };}Now, gcc accepts with no warning (gcc -std=c2x -pedantic -Werror)and clang rejects with -Werror because it diagnoses:error: address of array 'b' will always evaluate to 'true' [-Werror,-Wpointer-bool-conversion]bool a[2][3] = { b };^