Problem with your toolchain, not C++:
http://codepad.org/Tatd1iHD
http://liveworkspace.org/code/26fJ4j$0
Last edited on
I also get the output "hello kitty" but when I debug the code it does not step into catch block.
It works as expected for me on:
CentOS 5.2/gcc 4.1.2
ArchLinux/gcc 4.7.2
ArchLinux/icc 13.0.1
Code, x.cpp:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
|
#include <iostream>
#include <stdexcept>
int main()
{
std::string str = "hello";
try
{
throw std::out_of_range(str);
}
catch (const std::out_of_range& e)
{
std::cout << "std::out_of_range: " << e.what() << std::endl;
}
catch (const std::exception& e)
{
std::cout << "std::exception: " << e.what() << std::endl;
}
catch (...)
{
std:: cout << "error" << std::endl;
}
return 0;
}
|
Built with
make x
for gcc, and
make CXX=icc x
for Intel. (GNUMake doesn't need a make file for this.)
Last edited on
Thanks guys, I got it now.