使用 "itself" 初始化向量适用于 MSVC2013,不适用于 GCC 4.8.1
Initializing a vector with "itself" works with MSVC2013, not with GCC 4.8.1
使用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;
}
我认为你需要与warning level 4 or warning is an error
在visual studio和-Wall and -Werror or -Winit-self or -Wuninitialized
为ggcc.
编译,但是你有一个分配问题。
对我来说最好的标志是:-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
相关文章:
- 为什么我的 SFINAE 表达式不再适用于 GCC 8.2?
- 适用于 gcc 4.8 的任何正则表达式库
- 流输入运算符导致分段错误与 clang 但适用于 gcc
- -static-libstdc++ 适用于 g++ 但不适用于纯 gcc?
- enable_if的模板专用化在 Clang 中失败,适用于 GCC
- 函数指针数组的类模板参数推导适用于 clang,但不适用于 gcc
- 可变参数模板作为模板参数:演绎适用于 GCC,但不适用于 Clang
- -m32 选项不适用于 gcc,但适用于 g++
- 在哪里可以下载适用于 Windows 的 GCC 4.3.2 二进制文件
- gcc-fdiagnostics颜色是否适用于Windows
- 将 C++11 正则表达式与 gcc 4.8.2 一起使用时会出现奇怪的结果(但适用于 Boost 正则表达式)
- Netbeans 8.1(适用于 C/C++)找不到我的编译器(gcc-6.0.0 开发版本)
- 宏调用中的 #ifdef 适用于 GCC,但不适用于 MSVC
- 静态表生成适用于 GCC,但不适用于 clang;被叮当窃听
- 模板专用化适用于 gcc,但不适用于 Visual Studio 10
- c ++ 11 参数包在 Apple LLVM 7.0.0 中存在错误行为,但适用于 GCC-5.1
- 此代码有效吗?适用于 gcc,不要与 clang 合作
- 两层嵌套的c++类适用于GCC,但不适用于Clang
- 如何包装对"std::thread"构造函数的调用?(适用于gcc、VS和icpc)
- 可变参数模板转换为 std::function<R(ARGS...)>适用于 GCC 而不是 MSVC2013,为什么?