Patchwork Add missing explicit instantiation for std::lower_bound template

login
register
mail settings
Submitter Paolo Carlini
Date Feb. 5, 2013, 4:10 p.m.
Message ID <51112F05.2070404@oracle.com>
Download mbox | patch
Permalink /patch/218286/
State New
Headers show

Comments

Paolo Carlini - Feb. 5, 2013, 4:10 p.m.
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,
Paolo.

//////////////////
Dodji Seketeli - Feb. 6, 2013, 8:34 a.m.
Paolo Carlini <paolo.carlini@oracle.com> writes:

>> 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.

Ah, right.  It's true that I build on my machine without optimization so
that I can debug problems that show up on my local machine.  And I
always forget that I do that.

>> 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.

Great!  Your amendments work well for me.  I committed it to trunk.

Thank you.

Patch

Index: hashtable_c++0x.cc
===================================================================
--- hashtable_c++0x.cc	(revision 195759)
+++ hashtable_c++0x.cc	(working copy)
@@ -94,4 +94,11 @@  namespace __detail
 
 _GLIBCXX_END_NAMESPACE_VERSION
 } // 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