Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2008-07-11 10:28:46


on Thu Jul 10 2008, Steven Watanabe <watanabesj-AT-gmail.com> wrote:

> AMDG
>
> I'm looking at two recent posts:
> http://comments.gmane.org/gmane.comp.lib.boost.devel/177370
> http://comments.gmane.org/gmane.comp.lib.boost.user/37476
>
> Either of these is fine by itself, but putting them both
> together makes it very easy to cause silent ODR
> problems.

Heh, I just noticed the same issue.

> For example in translation unit a.cpp we
> #include "boost/tuple/tuple_io.hpp"
> and translation unit b.cpp we forget. Then, along comes
> boost::any which detects operator<< in translation
> unit a.cpp, but uses its default in translation unit
> b.cpp. Ka-Boom.
>
> This is not a huge problem at the moment, because it's
> quite difficult to make the detection bullet-proof,

I don't think that accurately characterizes the issue. I think few
compilers do anything to detect ODR violations. However, link-time
stripping of common template instantiations (or link-time instantiation)
seems likely to cause only a single behavior in both TUs where two
behaviors may have been intended.

> but I'm very concerned because C++0x concepts
> are supposed to make such overloading easy.

I'm not sure I see the relationship to C++0x concepts. Care to say
more?

-- 
Dave Abrahams
BoostPro Computing
http://www.boostpro.com

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk