Boost logo

Boost :

From: Arkadiy Vertleyb (vertleyb_at_[hidden])
Date: 2006-09-13 22:01:56


> Arkadiy Vertleyb wrote:
> > "Thorsten Ottosen" <thorsten.ottosen_at_[hidden]> wrote
> >
> >
> >>>>42 usages of unnamed namespaces in headers (including .ipp files)
> >>>
> >>>
> >>>>bind (1)
> >>>
> >>>
> >>>I'm not sure what I'm expected to do about that one. Bind has been
using
> >>>an
> >>>unnamed namespace for its placeholders for quite a while now.
> >>
> >>What is the problem with an unnamed namespace in a header anyway? Is it
> >>illegal according to the standard?
> >
> >
> > ODR is potentially violated :-(
> >
>
> How?

Suppose you have a class A defined inside unnamed namespace (in a header).
Suppose you also have a class B defined in terms of class A, but not inside
unnamed namespace (in the same or another header).

Now, if two translation units use the class B, the same class (B) is defined
differently in these translation units (since unnamed namespaces are
different and so B uses different A).

Typeof has a specific test causing this condition. So far no compilers
complained.

Regards,
Arkadiy


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