Re: Problem linking to wrong class

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Brian Peschel <brianp@xxxxxxxxxx> writes:

> Is there an option on the linker to at least warn me it is doing this?
> I understand why it is happening now (thanks!) at least.  But I am
> worried about this same problem elsewhere.  I expect this could happen
> to me with 3rd party libraries I use.  And unless a crash happens
> (like it did in this case with my own libraries), it would be
> difficult to diagnose.

There is not.  The problem is that duplicate symbols are normal in C++
code, due to C++ vague linkage, and they are not a problem provided that
the symbols all come from the same original definition.  In other words,
if there were such a linker option, it would be useless for C++ code
because there would be so many false positives.

The gold linker has a --detect-odr-violations option which will detect
some of thse cases but not all.  It looks at the debugging information
to see whether the two symbols appear to be coming from the same
definition.  This leads to a lot of false positives if you are
optimizing, so it's really only useful when using -O0 -g, and even then
it can have false negatives.

Ian

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux