That your code compiled without errors when there was only one flexible array member is because the GNU/GNU-compatible compiler is by default not a conforming C++ compiler.
Specify the size of the arrays, and compile with a C++ compiler (specify these options): g++ -std=c++14 -O3 -Wall -Wextra -pedantic-errors