Boost logo

Boost :

Subject: Re: [boost] version conflicts: is there a solution?
From: Ilya Bobir (ilya.bobir_at_[hidden])
Date: 2009-06-27 15:50:21


Ilya Bobir wrote:
> Frank Mori Hess wrote:
>> On Thursday 25 June 2009, Edward Diener wrote:
>>>> Can you point to anything in the standard that supports your position?
>>> Where in the standard do you see any mention of an ODR violation
>>> occuring where there are no header files being distributed for inclusion
>>> by a source file which would create such a violation ?
>>
>> There is the 3rd paragraph of the "one definition rule" section:
>>
>>
>> "Every program shall contain exactly one definition of every
>> non-inline function or object that is used in that program; no
>> diagnostic required. The definition can appear explicitly in the
>> program, it can be found in the standard or a user-defined library, or
>> (when appropriate) it is implicitly defined (see 12.1, 12.4 and 12.8).
>> An inline function shall be defined in every translation unit in which
>> it is used."
>>
>>
>> Note they include "user-defined library".
>>
>
> I think that in order to see the whole picture you need to explicitly
> define what a "definition" is. ISO 14882-2003 3.1 paragraphs 1st and 2nd:
>
> > A declaration (clause 7) introduces names into a translation unit or
> > redeclares names introduced by previous declarations. A declaration
> > specifies the interpretation and attributes of these names.
> >
> > A declaration is a /definition/ unless it declares a function without
> > specifying the function’s body (8.4), it contains the extern specifier
> > (7.1.1) or a linkage-specification24) (7.5) and neither an initializer
> > nor a function-body, it declares a static data member in a class
> > declaration (9.4), it is a class name declaration (9.1), or it is a
> > typedef declaration (7.1.3), a using-declaration (7.3.3), or a
> > using-directive (7.3.4).
>
> Unless your "user-defined library" include headers you can not introduce
> names into a translation unit. And even if it does include headers the
> ODR applies only to the stuff you have in that headers and not to the
> "rest" of the library. It means that unless you have the Boost headers
> somewhere in the header part of your library there is no way to violate
> the ODR as it applies to the translation units only.
>
> The linkage of compiled translation units is described in a separate
> section and has its own rules. Described in section "3.5 Program and
> linkage". While there is something similar to ODR there, see paragraph
> 9, but I do not think that it will apply to your case, unless you
> explicitly declare parts of boost as having external linkage thus making
> them visible to the linker during the linking process.
>

Artyom wrote:
> There are many problems and this is not as simple as you think.
> Because if you have two versions of foo() defined in header
> files they may be exported and... collide.

Oh, according to ISO 14882-2003 3.5 paragraph 4 all functions, names
classes and some other type of names defined in a namespace scope have
external linkage by default. It means that you will violate this rule.


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