问题
While reading the Clang documentation, I came across the following intriguing tidbit: [1]
clang does not support the gcc extension that allows variable-length arrays in structures. This is for a few reasons: one, it is tricky to implement, two, the extension is completely undocumented, and three, the extension appears to be rarely used. Note that clang does support flexible array members (arrays with a zero or unspecified size at the end of a structure).
How can this extension be used? My understanding is that using alloca within a constructor causes the stack pointer to be restored at the end of the calling function, which in this case would be the constructor -- not at the end of the enclosing struct.
Thanks for the help!
回答1:
See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37428
and also http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42121
Yes, it's weird.
来源:https://stackoverflow.com/questions/12058760/undocumented-gcc-extension-vla-in-struct