help-bison
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: std::string as YYSTYPE segfaults


From: Hans Aberg
Subject: Re: std::string as YYSTYPE segfaults
Date: Fri, 1 Mar 2002 18:47:40 +0100

At 11:06 +0100 2002/03/01, Magnus Ekhall wrote:
>> That's reason I use C++, because releases are kept track of via the
>>language.
>>
>
>That is why I tried C++ at first. But how can you make it run with C++ if
>the >{con | de | copycon}structors are not working properly?

The static stack is just an array, where the values are read in
successively by the parser; so there is no problem here.

However, when the stack runs out of memory, the current dynamic C stack
re-allocates it by firs allocating memory, and the writing in the old stack
values using memcpy(); so the C++ copy constructors are not called. Then,
depending on how your C++ classes are implemented, you may run into
problems with destructors as well, as they now may attempt to delete the
wrong things.

>Making your own parser does not count. ;-)

All that is needed is to make sure that the C++ parser is using a correct
C++ stack, for example std::deque, std::vector or std::list, instead of the
current C stack.

  Hans Aberg





reply via email to

[Prev in Thread] Current Thread [Next in Thread]