From: Hartmut Kaiser (hartmut.kaiser_at_[hidden])
Date: 2005-05-17 13:08:33
David Abrahams wrote:
> >> > This I don't understand anymore. The code in question is:
> >> >
> >> > some_spirit_grammar g;
> >> > boost::spirit::pt_parse(it, end, g);
> >> >
> >> > the programm crashes inside pt_parse because of g == 0xcccccccc
> >> > (destroyed object), where pt_parse takes 'g' by const reference.
> >> > Initially 'g' was defined as a function local static
> >> instance, which
> >> > I've removed now because I had the suspicion CW8.x couldn't
> >> handle that correctly.
> >> >
> >> > Any clues?
> >> > Regards Hartmut
> >> Are you running into the CW 8.3 "CRTP bug" where casting
> to a derived
> >> class reference can induce a copy?
> > That's possible, since Spirit passes the parser<> base class around
> > and casts it to the correct derived class (type supplied
> through CRTP)
> > when needed. Is there a known workaround?
> Yes, use
> instead of
Spirit does it this way (*static_cast<Derived*>(this)) and Wave simply
relies on Spirit. Seems that it's not the CRTP bug then. *sigh*
> > OTOH all the Spirit tests should fail if this assumption is correct.
> I wouldn't count on it. Temporaries can be deceptive. The
> memory may remain valid after destruction.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk