I'm initializing a nested array by passing each row separately.
The result is unexpected. See:
(gdb) li
1 #include <stdbool.h>
2 #include <stdio.h>
3
4 bool sa1[2] = (bool [2]){true, false};
5 bool sa2[2] = (bool [2]){false, false};
6 bool sa3[2] = (bool [2]){false, false};
7
8 bool sa[3][2] = {sa1, sa2, sa3};
9
10 int main() {
(gdb) print sa1
$1 = {true, false}
(gdb) print sa2
$2 = {false, false}
(gdb) print sa3
$3 = {false, false}
So far, all is as expected. However:
(gdb) print sa
$4 = {{true, true}, {true, false}, {false, false}}
I expected the value of sa
to contain sa1
, sa2
and sa3
, but it doesn't.
If I inline those expressions by hand, then it contains the expected values if I compile it with GCC, but not LLVM.
What is going on?