Reputation: 607
I have a very basic C++ program :-
#include <iostream>
#include <stdexcept>
int main(int argc, const char * argv[])
{
std::cout <<"Welcome .. "<<std::endl;
try {
throw std::runtime_error(std::string("Crazy exception"));
}
catch(std::exception& e) {
std::cerr << "error: " << e.what() << "\n";
exit(0);
} return 0;
}
Whenver I run this program, instead of an exception I see a Segmentation fault: 11
On the debugger, I see EXC_BAD_ACCESS(code=EXC_I386_GPFLT)
at the throw statement.
I have exceptions enabled on XCODE. Has anyone ever seen this kind of basic error ?
This is really killing me, should I re-install XCODE ? If yes, what's the way for clean install or something
Re-installed XCODE directly from APP STORE. Same issue !! Next is what ? Re-install the whole OSX i believe. Can someone give some clue what "can" be tried before I lounge into a brainless reformatting of the machine ?
Upvotes: 2
Views: 135
Reputation: 607
Re installed MAC OSX ! And it fixed the issue. Surprisingly there can be some OS corruption which may cause this.
Hopefully this would help someone else in future
Upvotes: 0
Reputation: 21
Yes, I have executed this program on my mac and it compiled successfully using every type of runtime error in <stdexcept>
. Which version of Xcode are you running? is it installed from the Apple store or some other website?
If you have installed it from Apple store please update Xcode version to Xcode 8.3.3 and run the code again.
In case you are using it from some other website, then there is a chance that it has a bug. I have also encountered a similar problem before.
There is a simple way to uninstall Xcode from your Mac. Drag Xcode from Finder in Applications and throw it in the Trash and Empty the Trash.
Upvotes: 1