[PATCH] Add missing explicit instantiation for std::lower_bound template

Paolo Carlini paolo.carlini@oracle.com
Tue Feb 5 16:10:00 GMT 2013

Hi Dodji,

On 02/04/2013 04:53 PM, Dodji Seketeli wrote:
> Hello,
> Since commit r195676[1], it looks like
> libstdc++-v3/src/c++11/hashtable_c++0x.cc is missing an explicit
> instantiation for std::lower_bound.  This leads to libstdc++.so having
> the symbol for that (missing) instantiation be undefined, thus
> preventing executables from being linked with libstdc++.
Note that I can confirm this only if I build with less optimization than 
the default -O2, say -O. That may explain why nobody noticed earlier.
> The patchlet below seems to fixed the issue for me.

Indeed, I think we want something like that. Thanks. In terms of nits, 
formatting and types (who knows, maybe on some systems a std::size_t is 
an unsigned long long), I would write something like the attached. 
Please double check that it works for you and go ahead.

Thanks again,


-------------- next part --------------
Index: hashtable_c++0x.cc
--- hashtable_c++0x.cc	(revision 195759)
+++ hashtable_c++0x.cc	(working copy)
@@ -94,4 +94,11 @@ namespace __detail
 } // namespace __detail
+  // Instantiation.
+  template
+  const unsigned long*
+  lower_bound<const unsigned long*, size_t>(const unsigned long*,
+					    const unsigned long*,
+					    const size_t&);
 } // namespace std

More information about the Gcc-patches mailing list