大佬教程收集整理的这篇文章主要介绍了c – gcc 4.9错误在结构初始化?,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
struct A { int a; }; struct B { int b; const A a[2]; }; struct C { int c; const B b[2]; }; const c test = {0,{}}; int main() { return test.c; }
我有gcc 4.8.2和4.9.2.它可以编译得很好:
g++-4.9 -Wall test.cpp -o test g++-4.8 -std=c++11 -Wall test.cpp -o test g++-4.8 -Wall test.cpp -o test
但是,它无法编译:
g++-4.9 -std=c++11 -Wall test.cpp -o test
编译器的输出是:
test.cpp:15:22: error: uninitialized const member ‘B::a’ const c test = {0,{}}; ^ test.cpp:15:22: error: uninitialized const member ‘B::a’
这是一个bug还是我只是不明白什么?
以上是大佬教程为你收集整理的c – gcc 4.9错误在结构初始化?全部内容,希望文章能够帮你解决c – gcc 4.9错误在结构初始化?所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。