Friday, 9 August 2013

C++ HelloWorld program compiled with MinGW crashes with "Illegal Argument"

C++ HelloWorld program compiled with MinGW crashes with "Illegal Argument"

I decided it was time that I learned C++, and after struggling for 3+
hours trying to get the compiler to work, I finally created a working
program. However, it seemingly spontaneously broke when I tried to
refactor the project in Eclipse by cutting and pasting it. The program
simply crashes, and Windows brings up the dreaded dialogue "HelloWorld.exe
has stopped working." A bit of debugging revealed that "cout" was
considered an illegal argument. I looked some more into the issue, and I'm
now suspicious that it has something to do with the compiler apparently
being 32-bit, as I have a 64-bit system. The executable is listed in
Eclipse as "HelloWorld.exe - [x86/le]." (Minus the period.) My program in
full is below:
#include <iostream>
using namespace std;
int main(){
cout << "Hello World!" << endl;
return 0;
}
I've also just discovered that creating a new "HelloWorld" C++ project in
Eclipse does absolutely nothing to fix the issue, even using the
unmodified code and settings. Anyone have any suggestions as to why this
would happen?
EDIT: Debugging information: Upon running the program:
Hello World!
Program received signal SIGNILL, Illegal instruction.
0x6fccc3c0 in libstdc++-6!_ZSt4cout ()
from C:\Windows\SysWOW64\libstdc++-6.dll
(gdb) bt
#0 0x6fccc3c0 in libstdc++-6~_ZSt4cout ()
from C:\Windows\SysWOW64\libstdc++-6.dll
#1 0x6fc8908c in libstdc++-6~_ZSt4cout ()
from C:\Windows\SysWOW64\libstdc++-6.dll
#2 0x004013be in libstdc++-6~_ZSt4cout () at HelloWorld.cpp:4
(gdb)
It should be noted that line 4 of the class now points to the cout call.

No comments:

Post a Comment