Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2005-05-17 10:22:15

Hartmut Kaiser <hartmut.kaiser_at_[hidden]> writes:

> 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


> 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.

Dave Abrahams
Boost Consulting

Boost list run by bdawes at, gregod at, cpdaniel at, john at