Hello,

A problem was detected.

If
%define parse.trace
is not specified in the grammar file then
the assertion is failed in value_type::~value_type.

Bison version: 3.8.2
Command-line:
bison -d -o @OUTPUT0@ --header=@OUTPUT1@ @INPUT@ --verbose

Grammar file:
%skeleton "glr2.cc"
%glr-parser
%language "c++"
%define api.value.type variant
%define api.token.constructor
%define parse.assert
%locations
%define parse.error verbose

In the generated parser, usually
value_type::destroy
is called before
value_type::~value_type

Otherwise, the assertion in value_type::~value_type may fail.

Incorrect behavior occurs in ~glr_state after initialization of
symbol_kind_type yykind = yy_accessing_symbol (yylrState);
The value of yykind is 0 (because yylrState is 0) and in the following
switch (yykind)
it goes to the 'default' were yyval.destroy is not called.

The correct value to yylrState is assigned in yyfillin,
but this happens if '%define parse.trace' was specified:
#if YYDEBUG
          yys.yylrState = s->yylrState;
#endif

The following fix to glr2.cc resolves the problem.

--- a/data/skeletons/glr2.cc
+++ b/data/skeletons/glr2.cc
@@ -1913,9 +1913,7 @@
       for (int i = yylow0-1; i >= yylow1; i -= 1, s = s->pred())
         {
           glr_state& yys = yyvsp[i].getState();
-#if ]b4_api_PREFIX[DEBUG
           yys.yylrState = s->yylrState;
-#endif
           yys.yyresolved = s->yyresolved;
           if (s->yyresolved)
             {]b4_variant_if([[

Attachment: glr2.cc.patch
Description: Binary data

Reply via email to