Boost logo

Boost :

Subject: Re: [boost] [Review] Boost.Convert library, last day
From: Matthew Chambers (matt.chambers42_at_[hidden])
Date: 2011-05-03 16:28:44


On 5/3/2011 3:05 PM, John Bytheway wrote:
> Finally, I am concerned by the prospect of ODR violations as a result of
> specialised conversions. Taking again the string-to-bool conversion as
> an example: if part of a program is compiled with this optimized
> implementation present, and part is compiled with it absent, then I
> suspect the program will be in violation of the ODR. This seems really
> quite dangerous. In particular, I see no safe way for me to write an
> optimized or otherwise customized implementation of any conversion
> unless either
>
> (a) it is distributed as part of Boost.Convert, and included
> unconditionally whenever the definition of convert is, or
>
> (b) it converts to or from a type A, and is included unconditionally
> whenever the definition of A is.
>
> Is the extension facility intended to be used in these limited
> circumstances? If so, then that fact must also be clearly and
> conspicuously documented. If not, then I would like to know how ODR
> violations are to be avoided.

I use an optional header that defines lexical_cast string->numeric specializations using strto[ld].
Is this at risk for ODR violations? I use it widely but I'm not at all careful about making sure
it's included everywhere. Yet I haven't had any ODR violations on GCC or MSVC. Unless that's pure
luck, I'd like to know how the optional specializations are ODR violations.

-Matt


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