0

I'm running this on a 3rd party statically linked library. I thought that since it's a header only library (except on some MSVC versions), it wouldn't show up. Maybe I'm misunderstanding what nm is supposed to show. What I really want to know is if they will cause ODR violations if I'm linking to a library that was compiled with a different version of Boost.

See output at: http://codepad.org/kJ86hiQg

A short sampling:

    W boost::exception_detail::clone_base::~clone_base()
    W boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<std::runtime_error> >::~clone_impl()
    W boost::exception_detail::cloning_base::~cloning_base()
    W boost::exception_detail::counted_base::~counted_base()
    W boost::exception::~exception()
Matt Chambers
  • 2,229
  • 1
  • 25
  • 43

1 Answers1

1

These appear to be weak symbols.

http://en.wikipedia.org/wiki/Weak_symbol


Update ODR violations are not caused by duplicate linker records in the first place. They are caused when the compiler uses different definitions of symbols by the same name.

So, the short answer is: no nm showing these weak symbols does not cause or indicate ODR violations. However, the fact that these symbols are weak doesn't imply that there cannot be a ODR violation either.

In fact I think it is perfectly possible to have ODR violations without such symbols (e.g. when the layout of a struct with the same mangled name is different due to different alignment or packing options) across translation units.

sehe
  • 374,641
  • 47
  • 450
  • 633
  • Sorry, I've modified the question to get at what I really want to know: whether it will cause ODR violations. – Matt Chambers Nov 19 '14 at 18:13
  • @MattChambers I've likewise expanded the answer. – sehe Nov 19 '14 at 19:11
  • I'm trying to understand whether a library (which I statically link to), using (potentially) different definitions of the header-only constructs provided by Boost.Exception, would cause ODRs if in fact those definitions are different. Of course if the objects with different definitions are passed between the client code and the library, that's an ABI problem. But if the library and my code only use those constructs internally, can there still be ODRs? I know with a compiled library like Boost.Regex, there can be. – Matt Chambers Nov 19 '14 at 23:22
  • If the code doesn't mix (e.g. if you adhere to the **["Hourglass API interfaces"](https://www.youtube.com/watch?v=PVYdHDm0q6Y)** guidelines) there is no issue. Consider this: at worst you'd get duplicate symbol errors/warnings from the linker, right? I guess there's a reason why these symbols are _weak_. – sehe Nov 19 '14 at 23:36