Boost logo

Boost Users :

Subject: Re: [Boost-users] program_options bad_any_cast in XCode
From: Thijs Koerselman (thijskoerselman.lists_at_[hidden])
Date: 2009-10-27 05:38:49


On Mon, Oct 26, 2009 at 7:48 PM, Jean-Denis Muys <jdmuys_at_[hidden]> wrote:
>
> I have been bitten by the following item in XCode 3.2.1 release notes:
>
> The default gcc 4.2 compiler is not compatible with the Standard C++ Library Debug Mode. C++ programs compiled with Xcode 3.2 may not work in the Debug configuration. To fix this, set the Compiler Version to 4.0, or edit the Debug configuration’s Preprocessor Macros and remove the entries:
>
> _GLIBCXX_DEBUG=1 _GLIBCXX_DEBUG_PEDANTIC=1
>
> I would say the likelihood this is happening to you is rather high.
> Please note that another possible workaround, beside the ones listed above, is to set the base SDK to 10.5

I've tried both gcc4.2 and 4.0 as well as 10.5 and 10.6 as base SDK. I
switched to XCode 3.2.1 as a last resort because I was using 3.2.0
before that which had the same issues.

I just discovered that if I remove the  _GLIBCXX_DEBUG=1
_GLIBCXX_DEBUG_PEDANTIC=1 for the debug configuration the program
works. Searching for the difference between debug (which is working)
and release (which is crashing), I first turned off optimization, but
without luck. I then narrowed it down to "Fix and Continue" or
GCC_ENABLE_FIX_AND_CONTINUE.

If this setting is disabled, the code crashes. Looking at the details
of this settings it says: Activating this setting will disable the
settings "Symbols Hidden by Default" and "Generate Position-Dependent
Code". Is any of these two settings the possible culprit?

If I don't use fix and continue, store() throws and exception like this:

#8 0x00004f6b in boost::throw_exception<boost::bad_any_cast> at
throw_exception.hpp:64
#9 0x00007c39 in boost::any_cast<std::string> at any.hpp:195
#10 0x00008673 in boost::program_options::validate<std::string, char>
at value_semantic.hpp:149
#11 0x0000884e in
boost::program_options::typed_value<std::vector<std::string,
std::allocator<std::string> >, char>::xparse at value_semantic.hpp:169
#12 0x000e17ae in
boost::program_options::value_semantic_codecvt_helper<char>::parse
#13 0x000deba7 in boost::program_options::store
#14 0x00001ae2 in main at main.cpp:42

At least I can now compile and run my program, but it would be nice to
know what the actual problem is here.

Cheers,
Thijs


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net