This is the mail archive of the mailing list for the libstdc++ project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] <stdexcept> visibility

I would like to get the following existing test:


to work correctly when the libstdc++ is compiled as a dynamic library and used with -fvisiblity=hidden from the command line. At issue is that (most of) the exceptions defined in <stdexcept> have no "key function" (reference abi.html#vague ), and thus their type_info's are emitted everywhere used. Since we compare type_info's only by address, when libstdc++ throw's an out_of_range, the client can't catch it because it has a local type_info for out_of_range that doesn't match the one internal to libstdc++.

We already wrap <exception> this way and for this purpose. The patch below does the same thing for <stdexcept>. I would also like to add a copy of testsuite/23_containers/vector/element_access/, named testsuite/23_containers/vector/element_access/ which has the single additional line:

// { dg-options "-fvisibility=hidden" }

Only I don't know the proper way to ask for a new file. :-)


Index: include/std/std_stdexcept.h
--- include/std/std_stdexcept.h (revision 108591)
+++ include/std/std_stdexcept.h (working copy)
@@ -43,6 +43,8 @@
#include <exception>
#include <string>
+#pragma GCC visibility push(default)
namespace std
/** Logic errors represent problems in the internal logic of a program;
@@ -144,4 +146,6 @@
} // namespace std
+#pragma GCC visibility pop
Index: ChangeLog
--- ChangeLog (revision 108591)
+++ ChangeLog (working copy)
@@ -1,3 +1,9 @@
+2005-12-15 Howard Hinnant <>
+ * Added pragma visibility wrappers around <stdexcept> as is already done
+ for <exception>. Added testsuite/23_containers/vector/ element_access/
+ to test for catching out_of_range when -fvisibility=hidden.
2005-12-15 Paolo Carlini <>
* include/bits/stl_vector.h (vector<>::_M_get_Tp_allocator): Change

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]