c++: reserve 200 slots in the parser's stack

This is consistent with what is done with yacc.c and glr.c.  Because
it also avoids that the stack needs to be resized very soon, it should
help keeping tests about destructors more reliable.

Indeed, if the stack is created too small, very soon the C++ library
needs to enlarge it, which means creating a new one, copying the
elements from the initial one onto it, and then destroy the elements
of the initial stack: that would be a spurious call to a destructor.

Reported by Thomas Jahns.
http://lists.gnu.org/archive/html/bug-bison/2015-01/msg00059.html

* data/stack.hh (stack::stack): Reserve 200 slots.
* tests/c++.at: Remove traces of stack expansions.
This commit is contained in:
Akim Demaille
2015-01-20 20:41:57 +01:00
parent 0b0370ff42
commit 573654ca9e
2 changed files with 3 additions and 5 deletions

View File

@@ -32,12 +32,12 @@ m4_define([b4_stack_define],
stack ()
: seq_ ()
{
seq_.reserve (200);
}
stack (unsigned int n)
: seq_ (n)
{
}
{}
inline
T&
@@ -114,8 +114,7 @@ m4_define([b4_stack_define],
slice (const S& stack, unsigned int range)
: stack_ (stack)
, range_ (range)
{
}
{}
inline
const T&

View File

@@ -342,7 +342,6 @@ AT_PARSER_CHECK([./list], 0,
]],
[[Destroy: ""
Destroy: "0"
Destroy: (0)
Destroy: 1
Destroy: "1"
Destroy: ()