|
Boost : |
From: Guillaume Melquiond (guillaume.melquiond_at_[hidden])
Date: 2007-06-10 04:18:34
Le samedi 09 juin 2007 à 18:43 -0400, Gennadiy Rozental a écrit :
> > > Can anyone explain why unnamed namespace is a problem?
> >
> > Inline functions referring to the content of an unnamed namespace will
> > break the one-definition rule, when their header is included several
> > times. Undefined behavior ensues.
>
> I don't mean in general. static vars have the same issue. I mean why is it
> reported by our tools?
I don't mean in general either. The example I give you is based on your
very own files. They contain unnamed namespaces used from inline
functions, hence they are not compliant with the C++ standard.
For example, see the token_iterator.hpp file detected by the inspection
reports. The keep_empty_tokens variable is defined in an unnamed
namespace but used in an inline function, so the one that is passed as
an argument to the function may not be identical to the one the function
tests for.
Not that it may change anything, but this is not standard C++, which is
a bit unfortunate for a Boost library. Moreover, it artificially
increases the linking time and the size of the execution files for no
good reason.
Best regards,
Guillaume
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk