以下代码使用GCC 4.8.1打印0
(为什么不打),但使用MSVC2013打印10
(为什么?):
#include <iostream>
#include <vector>
const int y = 10;
int main()
{
std::vector<double> y(y);
std::cout << y.size() << std::endl;
return 0;
}
答案 0 :(得分:0)
我认为你需要编译
视觉工作室中的warning level 4 or warning is an error
和
ggcc -Wall and -Werror or -Winit-self or -Wuninitialized
编译,但你有分配问题。
对我来说,最好的标志是:
-std=c++11 -pipe -m64 -ansi -fPIC -g -O3 -fno-exceptions -fstack-protector -Wl,-z,relro -Wl,-z,now -fvisibility=hidden -W -Wall -Wno-unused-parameter -Wno-unused-function -Wno-unused-label -Wpointer-arith -Wformat -Wreturn-type -Wsign-compare -Wmultichar -Wformat-nonliteral -Winit-self -Wuninitialized -Wno-deprecated -Wformat-security -Werror