In the user's manual, section GCC extensions not implemented yet, I read:

clang does not support static initialization of flexible array members. This 
appears to be a rarely used extension, but could be implemented pending user 

I interpret this to say that the following program would not work, because bar would not be allocated space for an array y of three elements:

        struct foo {
                int x;
                int y[];

        struct foo bar = {1, {2, 3, 4}};

However, testing shows that it does work and there is in fact a similar test case (https://github.com/llvm-mirror/clang/blob/master/test/Sema/flexible-array-init.c). A warning "flexible array initialization is a GNU extension" is printed only if -Wpedantic is enabled.

Am I reading the documentation wrong or is this a documentation error?

Best Regards,
Anton Eliasson
cfe-users mailing list

Reply via email to