Gos*_*low 0 c c++ language-lawyer
如果我有这样的代码
struct s { int x; char b[]; };
int main() {
struct s s[10];
}
Run Code Online (Sandbox Code Playgroud)
我用“gcc -O2 -W -Wall -pedantic”进行编译,然后我得到:
<source>:4:14: warning: invalid use of structure with flexible array member [-Wpedantic]
4 | struct s s[10];
| ^
Run Code Online (Sandbox Code Playgroud)
gcc 是完全正确的。具有灵活数组成员的结构不能这样工作。
C/C++ 标准中的什么地方定义了这个?