diff options
author | Akim Demaille <akim@lrde.epita.fr> | 2015-01-20 20:41:57 +0100 |
---|---|---|
committer | Akim Demaille <akim@lrde.epita.fr> | 2015-01-20 20:45:48 +0100 |
commit | 573654ca9e8bc3ad9f5a00820417edcbca6e14dc (patch) | |
tree | 54fa97b51ef750c9c31f4c4e674ec7dc0d1b6014 | |
parent | 0b0370ff42af17689da7edf28294a5262e450610 (diff) | |
download | bison-573654ca9e8bc3ad9f5a00820417edcbca6e14dc.tar.gz |
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.
-rw-r--r-- | data/stack.hh | 7 | ||||
-rw-r--r-- | tests/c++.at | 1 |
2 files changed, 3 insertions, 5 deletions
diff --git a/data/stack.hh b/data/stack.hh index e7ff0405..a56e6c74 100644 --- a/data/stack.hh +++ b/data/stack.hh @@ -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& diff --git a/tests/c++.at b/tests/c++.at index 062e5f08..55d7d403 100644 --- a/tests/c++.at +++ b/tests/c++.at @@ -342,7 +342,6 @@ AT_PARSER_CHECK([./list], 0, ]], [[Destroy: "" Destroy: "0" -Destroy: (0) Destroy: 1 Destroy: "1" Destroy: () |