Boost logo

Boost :

From: Sebastian Redl (sebastian.redl_at_[hidden])
Date: 2007-06-14 11:08:10


Arkadiy Vertleyb wrote:
> The main problem of unnamed namespaces in headers is the possibility of ODR
> violation. Has anyone seen any compiler complain about this?
Not this case specifically, although I've seen complaints about more
obvious violations of the ODR, e.g. when you try to link against two
versions of the CRT in Visual C++. (Typically because you specify one
and a static library you include has another in its dependencies.)
> Now, I don't know if this is an appropriate topic here, but I would question
> the usefullness of the ODR itself.
The ODR is a logical necessity, not a feature that may be useful or not.
If the compiler generates two differing definitions of a symbol, how can
the linker possibly know which one to use? And if it doesn't know which
one to use, how can the program have defined behaviour?
A better question would be whether to relax the ODR such that
"equivalent" (under specific rules) multiple definitions do not cause
the ODR to be violated, similar to what is already done for template
instantiations.
> My main problem with it -- it
> contradicts to quite useful, IMO, idiom, where a library author defines a
> main template in his/her library as a customization point, and the users
> provide specializations of this template (similar to virtual functions in
> runtime world).
>
What does this have to do with the ODR?

Sebastian Redl


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