Here is my gcc information: % gcc -v Using built-in specs. Target: powerpc-apple-darwin8 Configured with: /private/var/tmp/gcc/gcc-5250.obj~12/src/configure --disable-checking -enable-werror --prefix=/usr --mandir=/share/man --enable-languages=c,objc,c++,obj-c++ --program-transform-name=/^[cg][^.-]*$/s/$/-4.0/ --with-gxx-include-dir=/include/c++/4.0.0 --build=powerpc-apple-darwin8 --host=powerpc-apple-darwin8 --target=powerpc-apple-darwin8 Thread model: posix gcc version 4.0.1 (Apple Computer, Inc. build 5250)
Here is the code that reproduces the error: --- snip --- #include <iostream> #include <vector> #include <stdexcept> int main (int argc, char * const argv[]) { try { std::vector<int> intVector; intVector.at(0); } catch (std::out_of_range &) { std::cout << "Caught std::out_of_range" << std::endl; } std::cout << "Finished normally" << std::endl; return 0; } --- snip --- Here is the error output: % g++ -fvisibility=hidden -o catch main.cpp % ./catch terminate called after throwing an instance of 'std::out_of_range' what(): vector::_M_range_check zsh: abort ./catch % Here is the expected output: % g++ -o catch main.cpp % ./catch Caught std::out_of_range Finished normally % This problem occurs because std::out_of_range is not marked with default visibility. This issue is documented here (see the section on Problems with C++ exceptions): http://gcc.gnu.org/wiki/Visibility The <stdexcept> header file needs to be wrapped in: #pragma GCC visibility push(default) ... #pragma GCC visibility pop Just like <exception> is. This can be verified by modifying the program above as: --- snip --- #include <iostream> #include <vector> #pragma GCC visibility push(default) #include <stdexcept> #pragma GCC visibility pop int main (int argc, char * const argv[]) { try { std::vector<int> intVector; intVector.at(0); } catch (std::out_of_range &) { std::cout << "Caught std::out_of_range" << std::endl; } std::cout << "Finished normally" << std::endl; return 0; } --- snip --- -- Summary: The <stdexcept> header is not setting default visibility Product: gcc Version: 4.0.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: gcc at dave dot dribin dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26217