C++ C++;使用auto_ptr或删除阵列时程序崩溃

C++ C++;使用auto_ptr或删除阵列时程序崩溃,c++,windows,gcc,C++,Windows,Gcc,我在Windows下使用g++(带cygwin)。当我使用auto_ptr或删除阵列时,我的程序崩溃。 这是两个在运行时崩溃的示例。我没有得到任何编译错误 gcc版本为5.2.0-1 我用 g++-O3-g0-Wall-c-fmessage length=0-std=c++14-MMD-MP-MF“src/PtrTest.d”-MT“src/PtrTest.o”-o“src/PtrTest.o”“../src/PtrTest.cpp” 例1: #include <iostream>

我在Windows下使用g++(带cygwin)。当我使用auto_ptr或删除阵列时,我的程序崩溃。 这是两个在运行时崩溃的示例。我没有得到任何编译错误

gcc版本为5.2.0-1

我用
g++-O3-g0-Wall-c-fmessage length=0-std=c++14-MMD-MP-MF“src/PtrTest.d”-MT“src/PtrTest.o”-o“src/PtrTest.o”“../src/PtrTest.cpp”

例1:

#include <iostream>
#include <memory>
int main() {
    std::auto_ptr<int> test1(new int);

    return 0;
}
#包括
#包括
int main(){
std::自动测试1(新int);
返回0;
}
例2:

#include <iostream>
#include <array>

int main() {
    std::array<int, 4> *a = new std::array<int,4>;
    delete a;

    return 0;
}
#包括
#包括
int main(){
std::array*a=新的std::array;
删除一条;
返回0;
}
有什么想法吗


多谢各位

“撞车”是什么意思?gdb是怎么说的?注意,在C++11中,std::auto_ptr已被弃用,并已被std::unique_ptrgdb所取代:[新线程96.0x1bdc]gdb:0x7FFC6EFEC4E0处的未知目标异常0xc0000139使用unique_ptr时出现相同问题。但是当我使用微软的Visual Studio而不是g++时,我没有问题。代码很好。还有别的问题。如果你们都能给我们一个编译器命令,该命令实际生成一个可执行文件而不是.o文件,并且可能会在像ideone或coliru这样的在线编译器中重现您的问题,那么我们可以帮助您。