未记录的GCC扩展:结构中的VLA [英] Undocumented GCC Extension: VLA in struct
问题描述
在阅读Clang文档时,我遇到了以下引人入胜的tidbit: [1]
While reading the Clang documentation, I came across the following intriguing tidbit: [1]
clang不支持在结构中允许可变长度数组的gcc扩展。这是由于几个原因:一,它是难以实现,二,扩展是完全没有记录,三,扩展似乎很少使用。请注意,clang支持灵活的数组成员(在结构末尾具有零或未指定大小的数组)。
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).
扩展名?我的理解是,在构造函数中使用alloca会导致堆栈指针在调用函数结束时恢复,在这种情况下将是构造函数,而不是在结构化结构的末尾。
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.
感谢您的帮助!
推荐答案
请参阅http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37428
以及 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42121
是的,很奇怪。
这篇关于未记录的GCC扩展:结构中的VLA的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!