const QList<int> warnings = QList<int>() << 0; segfaults with gcc 4.7.2

≡放荡痞女 提交于 2019-12-05 13:57:32

My psychic debugging powers tell me that the line in question exists at global/file scope, not at class/function scope. Thus your line may be called at any point during static initialization. With your old gcc it just so happened that QT was initialized before your line was called. With the new gcc it reordered (perfectly legal) the static init to call your function first, before QT was ready to create objects and insert into them.

The solution is to hold off on creating that QList until after main starts. Using pointers or static local objects are two common implementations.

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