This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: Crash due to mis-bind of a libstdc++ symbol
On Mon, Apr 18, 2005 at 12:18:51AM +0100, Mike Hearn wrote:
> On Sun, 17 Apr 2005 21:41:27 +0100, Mike Hearn wrote:
> > I haven't fully investigated what is going on here, but for some reason a
> > v5 symbol takes precedence over the v6 symbol despite the use of symbol
> > versioning.
>
> I have a small test case. It doesn't crash, but it does show the
> mis-bind. What appears to be happening is this.
>
> The STL string + operator overload is defined inline. ...
I had started to compose a message to you on the gcc thread suggesting
"look at gnu.linkonce", meaning that there might be an issue with how
the linker choosing the "wrong" version of a template function. Sounds
like I was on the right track.
> In other words, both the program "yyy" and "libxxx" contain the a copy of
> the std::string + operator. These are both defined as weak symbols,
> meaning that they are bound to the first definition in an image. I do not
> understand why this is so: I thought methods defined in headers would
> be inlined into the code, not emitted into the binary as a symbol.
No; templates that aren't defined as inline are COMDAT: they might be
instantiated in multiple object files and the linker is told to pick one.