From: Akim Demaille Date: Tue, 20 Jan 2015 19:41:57 +0000 (+0100) Subject: c++: reserve 200 slots in the parser's stack X-Git-Tag: v3.0.4~5 X-Git-Url: https://git.saurik.com/bison.git/commitdiff_plain/573654ca9e8bc3ad9f5a00820417edcbca6e14dc?ds=sidebyside 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. --- 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: ()