I met the same problem on Linux, and I find that it only appears build with -O0
or -D_GLIBCXX_ASSERTIONS
With gdb, I tried to debug
void
yyremoveDeletes ()
{
size_t newsize = yystates.size ();
/* j is the number of live stacks we have seen. */
for (size_t i = 0, j = 0; j < newsize; ++i)
{
if (yystates[i] == YY_NULLPTR)
{
if (i == j)
{
YYCDEBUG << "Removing dead stacks.\n";
}
newsize -= 1;
}
else
{
yystates[j] = yystates[i];
/* In the current implementation, it's unnecessary to copy
yylookaheadNeeds[i] since, after
yyremoveDeletes returns, the parser immediately either enters
deterministic operation or shifts a token. However, it doesn't
hurt, and the code might evolve to need it. */
yylookaheadNeeds[j] = yylookaheadNeeds[i];
if (j != i)
{
YYCDEBUG << "Rename stack " << i << " -> " << j << ".\n";
}
j += 1;
}
}
yystates.resize (newsize);
yylookaheadNeeds.resize (newsize);
}
`yylookaheadNeeds[j] = yylookaheadNeeds[i];` do have some problems:
In the 3rd time we use `yyremoveDeletes`, the length of `yystates` is 1, while
the
length of yylookaheadNeeds is 0.