[config] Proposed new defect macro : BOOST_NO_IMPLICIT_BOOL_CONVERSION

Attached is the test file for a proposed new defect macro, BOOST_NO_IMPLICIT_BOOL_CONVERSION. This identifies compilers (such as Borland) that do not always convert expressions to bool as required by 5.14/5.15 and elsewhere. The workaround is fairly simple - detect the bad compiler and add an additional static_cast<bool>( ) around the (sub)expression. This only really catches classes relying on the convertible-to-unspecified-bool-type idiom. The test results I am posting have applied this workaround in a number of places, and obviously I would prefer to post those patches with a defect macro rather than compiler (and version) specific workarounds. Note: the tests checks all 'boolean contexts', not just the two or three that fail with Borland. I don't know if this will catch any other compilers. As ever, I am open to suggestions for a better name. -- AlisdairM

On 6/5/07, AlisdairM <alisdair.meredith@uk.renaultf1.com> wrote:
Attached is the test file for a proposed new defect macro, BOOST_NO_IMPLICIT_BOOL_CONVERSION.
Hi! I have recently transalated Boost.Config Docs to qbk... please update they too if you add this macro. Sorry for the hassle, it will be over once we settle with the new qbk docs Regards! Matias

AlisdairM wrote:
Attached is the test file for a proposed new defect macro, BOOST_NO_IMPLICIT_BOOL_CONVERSION.
This identifies compilers (such as Borland) that do not always convert expressions to bool as required by 5.14/5.15 and elsewhere. The workaround is fairly simple - detect the bad compiler and add an additional static_cast<bool>( ) around the (sub)expression.
This only really catches classes relying on the convertible-to-unspecified-bool-type idiom.
The test results I am posting have applied this workaround in a number of places, and obviously I would prefer to post those patches with a defect macro rather than compiler (and version) specific workarounds.
Note: the tests checks all 'boolean contexts', not just the two or three that fail with Borland. I don't know if this will catch any other compilers.
As ever, I am open to suggestions for a better name.
Looks fine to me, please go ahead with this, John.
participants (3)
-
AlisdairM
-
John Maddock
-
Matias Capeletto