Overview
Features
Download
Documentation
Community
Add-Ons & Services

Problem with SampleApp in Utilities

Please post support and help requests here.

Problem with SampleApp in Utilities

Postby merdem » 22 Aug 2006, 23:24

Hello,

When I try to run the SampleApp under Utilities, I get inconsistent results.

My platform is VS8.

When SampleApp is run in debug mode with a single command argument, say /h, it gives an "Expression: vector iterators incompatible" assertion error. I tracked this error to be generated at:

Filename: application.cpp
Line: 298

_args.erase(_args.begin());
ArgVec::iterator it = _args.begin();
(:arrow:) while (it != _args.end())
{
std::string name;
std::string value;
if (processor.process(*it, name, value))
{
handleOption(name, value);
_args.erase(it);
}
else ++it;
}

Strangely enough in release mode everything works fine.

Can you help me?
merdem
 
Posts: 14
Joined: 19 Jul 2006, 22:28

Re: Problem with SampleApp in Utilities

Postby merdem » 22 Aug 2006, 23:40

> Hello,
>
> When I try to run the SampleApp under Utilities, I get inconsistent results.
>
> My platform is VS8.
>
> When SampleApp is run in debug mode with a single command argument, say /h, it gives an "Expression: vector iterators incompatible" assertion error. I tracked this error to be generated at:
>
> Filename: application.cpp
> Line: 298
>
> _args.erase(_args.begin());
> ArgVec::iterator it = _args.begin();
> (:arrow:) while (it != _args.end())
> {
> std::string name;
> std::string value;
> if (processor.process(*it, name, value))
> {
> handleOption(name, value);
> _args.erase(it);
> }
> else ++it;
> }
>
> Strangely enough in release mode everything works fine.
>
> Can you help me?


I found the problem...Erasing an iterator of a vector invalidates it. So, the return value of erase(iterator) should be used to update the iterator, i.e.:

_args.erase(_args.begin());
ArgVec::iterator it = _args.begin();
while (it != _args.end())
{
std::string name;
std::string value;
if (processor.process(*it, name, value))
{
handleOption(name, value);
(:arrow:) it = _args.erase(it);
}
else ++it;
}



cheers! (:biggrin:)
merdem
 
Posts: 14
Joined: 19 Jul 2006, 22:28

Re: Re: Problem with SampleApp in Utilities

Postby peter » 23 Aug 2006, 08:21

> > Hello,
> >
> > When I try to run the SampleApp under Utilities, I get inconsistent results.
> >
> > My platform is VS8.
> >
> > When SampleApp is run in debug mode with a single command argument, say /h, it gives an "Expression: vector iterators incompatible" assertion error. I tracked this error to be generated at:
> >
> > Filename: application.cpp
> > Line: 298
> >
> > _args.erase(_args.begin());
> > ArgVec::iterator it = _args.begin();
> > (:arrow:) while (it != _args.end())
> > {
> > std::string name;
> > std::string value;
> > if (processor.process(*it, name, value))
> > {
> > handleOption(name, value);
> > _args.erase(it);
> > }
> > else ++it;
> > }
> >
> > Strangely enough in release mode everything works fine.
> >
> > Can you help me?

Thanks for your report but I fear you are working with an old poco release?
This bug is already fixed in the current 1.2 beta.
And although 1.2 is still considered beta, I recommend to update to it.
Main reason being that we got rid of the namespace macros and introduced the
root Poco namespace (which will require you to do a few find/replace commands
on your source code so that everything compiles again. Not much work!).
It contains bug fixes and some extensions which you might find useful (also to options processing, required options are now checked) :-)
A complete changelist is available here:

http://sourceforge.net/project/shownotes.php?group_id=132964&release_id=441434

best regards,
Peter
peter
 
Posts: 67
Joined: 11 Jul 2006, 16:26
Location: Austria


Return to Support

Who is online

Users browsing this forum: No registered users and 3 guests

cron