diff mbox

[DOC] Describe VLAs in struct/union (PR c/37428)

Message ID 20140325160538.GR6523@redhat.com
State New
Headers show

Commit Message

Marek Polacek March 25, 2014, 4:05 p.m. UTC
We should mention this GNU C extension in the manual.

Ok?

2014-03-25  Marek Polacek  <polacek@redhat.com>

	PR c/37428
	* doc/extend.texi (C Extensions): Mention variable-length arrays in
	a structure/union.


	Marek

Comments

Joseph Myers March 25, 2014, 10:03 p.m. UTC | #1
On Tue, 25 Mar 2014, Marek Polacek wrote:

> We should mention this GNU C extension in the manual.
> 
> Ok?
> 
> 2014-03-25  Marek Polacek  <polacek@redhat.com>
> 
> 	PR c/37428
> 	* doc/extend.texi (C Extensions): Mention variable-length arrays in
> 	a structure/union.

OK.
diff mbox

Patch

diff --git gcc/doc/extend.texi gcc/doc/extend.texi
index 986cc94..b564ade 100644
--- gcc/doc/extend.texi
+++ gcc/doc/extend.texi
@@ -1592,6 +1592,18 @@  Jumping or breaking out of the scope of the array name deallocates the
 storage.  Jumping into the scope is not allowed; you get an error
 message for it.
 
+@cindex variable-length array in a structure
+As an extension, GCC accepts variable-length arrays as a member of
+a structure or a union.  For example:
+
+@smallexample
+void
+foo (int n)
+@{
+  struct S @{ int x[n]; @};
+@}
+@end smallexample
+
 @cindex @code{alloca} vs variable-length arrays
 You can use the function @code{alloca} to get an effect much like
 variable-length arrays.  The function @code{alloca} is available in