[cfe-users] Static initialization of flexible array members

Anton Eliasson via cfe-users cfe-users at lists.llvm.org
Thu Feb 8 05:52:04 PST 2018


Hi!
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 demand.

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



More information about the cfe-users mailing list