Undocumented GCC Extension: VLA in struct

纵然是瞬间 提交于 2020-01-19 05:42:23

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!