Boost logo

Boost Users :

From: Joaquín Mª López Muñoz (joaquin_at_[hidden])
Date: 2006-05-25 02:38:23


Edson Tadeu ha escrito:

> Joaquín,
>
> Actually I tried to simplify into a test case a code in a real
> application I was debugging, but I forgot to put a line in it:
>
> using boost::format;
> format f("%0s%-32.32s:%|40t|%|.6|%|55t|%25s\n ");
> f.bind_arg(1,"");
> f % "test1" % 2.0 % "test3";
> f % "test4" % 5.0 % "test6"; // calls clear() and breaks
>
> It didn't call clear() explicitly, but operator%() automatically calls
> it to refresh to a new string. Your test does the same thing and is
> much clearer and simpler. I got a crash on your code too, when
> debugging on msvc 7.
>
> I changed the offending line to:
>
> if( bound_.size()==0 || (items_[i].argN_ >= 0) && !bound_[
> items_[i].argN_ ] )
>
> And now it is ok here!

I'd say the following is marginally more correct

            if( bound_.size()==0 || items_[i].argN_<0 || !bound_[
items_[i].argN_ ] )

because it clears items_[i].res_ in exactly every case except for bound
args
while your formulation omits items_[i].res_ clearing in more cases than
bound
args, namely also for items_[i].argN_<0. Anyway, it probably does not
matter
much. Does this formulation still solve your crash? I'm posting this a a
patch
proposal in a separate post.

Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo


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