From 573654ca9e8bc3ad9f5a00820417edcbca6e14dc Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Tue, 20 Jan 2015 20:41:57 +0100 Subject: [PATCH] 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. --- data/stack.hh | 7 +++---- 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: () -- 2.45.2