string iterator not dereferencable

Hi all, I am newbie and I am developing in C++ using VC9, Boost 1.37, CPLEX 11.1. I use date_time and program_options boost libraries and my program compiles fine. Date_time works perfectly while program_options gives me a runtime error saying "Debug assertion failed .... string iterator not dereferencable" every time I pass any argument in the command line. The assertion fails at line 112 of "C:\program files\microsoft visual studio 9.0\vc\include\xstring" So I try to figure out what was going on in the following way: - I tried "first.cpp" in program option example directory on a new project: it works with no problem. -Then I tried to replace the main function of my project with the exact code of "first.ccp" and I got "string iterator not dereferencable" again. Can anyone help me ? Many thanks in advance Alessandro

On Fri, Feb 6, 2009 at 10:30 AM, Alessandro Condotta <gale82@gmail.com> wrote:
Hi all, I am newbie and I am developing in C++ using VC9, Boost 1.37, CPLEX 11.1. I use date_time and program_options boost libraries and my program compiles fine. Date_time works perfectly while program_options gives me a runtime error saying "Debug assertion failed .... string iterator not dereferencable" every time I pass any argument in the command line. The assertion fails at line 112 of "C:\program files\microsoft visual studio 9.0\vc\include\xstring"
So I try to figure out what was going on in the following way:
- I tried "first.cpp" in program option example directory on a new project: it works with no problem.
-Then I tried to replace the main function of my project with the exact code of "first.ccp" and I got "string iterator not dereferencable" again.
Can anyone help me ?
This is just a "stab in the dark" as you've had no other replies, and I've never used program_options. If first.cpp works in a new project, but not in your project, then it sounds like you should compare the compiler/linker settings on your project with the new project that just contains first.cpp. Regards, Pete

Thank you for replying. I checked the options and over but I couldn't find any difference.. :( I posted the trace of the stack in my reply to Alex. I leave it there for while and I will check for the problem again with a fresher mind. Alessandro On Fri, Feb 6, 2009 at 9:25 PM, Peter Barker <newbarker@gmail.com> wrote:
On Fri, Feb 6, 2009 at 10:30 AM, Alessandro Condotta <gale82@gmail.com> wrote:
Hi all, I am newbie and I am developing in C++ using VC9, Boost 1.37, CPLEX 11.1. I use date_time and program_options boost libraries and my program compiles fine. Date_time works perfectly while program_options gives me a runtime error saying "Debug assertion failed .... string iterator not dereferencable" every time I pass any argument in the command line. The assertion fails at line 112 of "C:\program files\microsoft visual studio 9.0\vc\include\xstring"
So I try to figure out what was going on in the following way:
- I tried "first.cpp" in program option example directory on a new project: it works with no problem.
-Then I tried to replace the main function of my project with the exact code of "first.ccp" and I got "string iterator not dereferencable" again.
Can anyone help me ?
This is just a "stab in the dark" as you've had no other replies, and I've never used program_options.
If first.cpp works in a new project, but not in your project, then it sounds like you should compare the compiler/linker settings on your project with the new project that just contains first.cpp.
Regards,
Pete _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users

I am newbie and I am developing in C++ using VC9, Boost 1.37, CPLEX 11.1. I use date_time and program_options boost libraries and my program compiles fine. Date_time works perfectly while program_options gives me a runtime error saying "Debug assertion failed .... string iterator not dereferencable" every time I pass any argument in the command line. The assertion fails at line 112 of "C:\program files\microsoft visual studio 9.0\vc\include\xstring"
When you get the assertion failure, have a look at the back trace to find out which line in program_options and which line of your code it is coming from, maybe that will give more clues. If you're still stuck it is helpful if you can post a *small* but complete code snippet that can reproduce your problem, as there may be something very simple that you're doing wrong. Alex

Thank you for replying. As I explained, I deleted my main method and I inserted first.cpp (boost program_option example) in my project. It compiles f but when I pass an options to the command line (ex. --help) the assertion fails. Note that the program has no problem if no parameter is passed to the command line. Back trace from the program shows that the line of boost code that trigger the assertion is line 63 of options_description.cpp: - if (*m_long_name.rbegin() == '*') The trace is the following: msvcp90d.dll!std::_Debug_message(const wchar_t * message=0x017f7918, const wchar_t * file=0x017f7778, unsigned int line=112) Line 24 C++ SchedulerModel.exe!std::_String_const_iterator<char,std::char_traits<char>,std::allocator<char>
::operator*() Line 112 + 0x14 bytes C++ SchedulerModel.exe!std::_Revranit<std::_String_const_iterator<char,std::char_traits<char>,std::allocator<char> ,std::iterator<std::random_access_iterator_tag,char,int,char const *,char const &> >::operator*() Line 1910 + 0xf bytes C++ SchedulerModel.exe!boost::program_options::option_description::match(const std::basic_string<char,std::char_traits<char>,std::allocator<char> > & option="help", bool approx=true) Line 63 + 0x28 bytes C++ SchedulerModel.exe!boost::program_options::options_description::find_nothrow(const std::basic_string<char,std::char_traits<char>,std::allocator<char> > & name="help", bool approx=true) Line 269 + 0x26 bytes C++ SchedulerModel.exe!boost::program_options::detail::cmdline::finish_option(boost::program_options::basic_option<char> & opt={...}, std::vector<std::basic_string<char,std::char_traits<char>,std::allocator<char> ,std::allocator<std::basic_string<char,std::char_traits<char>,std::allocator<char>
& other_tokens=[0]()) Line 294 + 0x28 bytes C++ SchedulerModel.exe!boost::program_options::detail::cmdline::run() Line 238 C++ SchedulerModel.exe!boost::program_options::basic_command_line_parser<char>::run() Line 102 + 0xf bytes C++ SchedulerModel.exe!boost::program_options::parse_command_line<char>(int argc=2, char * * argv=0x00174e88, const boost::program_options::options_description & desc={...}, int style=0, boost::function1<std::pair<std::basic_string<char,std::char_traits<char>,std::allocator<char> ,std::basic_string<char,std::char_traits<char>,std::allocator<char> > ,std::basic_string<char,std::char_traits<char>,std::allocator<char> > const &> ext={...}) Line 119 + 0x8d bytes C++ SchedulerModel.exe!main(int ac=2, char * * av=0x00174e88) Line 27 + 0x39 bytes C++ SchedulerModel.exe!__tmainCRTStartup() Line 582 + 0x19 bytes C SchedulerModel.exe!mainCRTStartup() Line 399 C
Since I am using cplex library, can it be that this problem is triggered by a particular method/function in such a library ? (date_time works perfectly) Thank you again Alessandro On Fri, Feb 6, 2009 at 10:43 PM, Alex MDC <alex.mdc@gmail.com> wrote:
I am newbie and I am developing in C++ using VC9, Boost 1.37, CPLEX 11.1. I use date_time and program_options boost libraries and my program compiles fine. Date_time works perfectly while program_options gives me a runtime error saying "Debug assertion failed .... string iterator not dereferencable" every time I pass any argument in the command line. The assertion fails at line 112 of "C:\program files\microsoft visual studio 9.0\vc\include\xstring"
When you get the assertion failure, have a look at the back trace to find out which line in program_options and which line of your code it is coming from, maybe that will give more clues.
If you're still stuck it is helpful if you can post a *small* but complete code snippet that can reproduce your problem, as there may be something very simple that you're doing wrong.
Alex
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
participants (4)
-
Alessandro Condotta
-
Alex MDC
-
gale82
-
Peter Barker