[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

C++ std::move issue

From: Hans Åberg
Subject: C++ std::move issue
Date: Wed, 21 Sep 2022 15:08:09 +0200

In Bison 3.8.1, there may be a double application of std::move on the semantic 
value under some circumstances, which may be valid C++, but not intended. A 
std::move should leave the object in a valid but unspecified state, which 
probably means that assignments should be still possible.

In the parser, there is a std::move in:
    /* Initialize the stack.  The initial state will be set in
       yynewstate, since the latter expects the semantical and the
       location values to have been already stored, initialize these
       stacks with a primary value.  */
    yystack_.clear ();
    yypush_ (YY_NULLPTR, 0, YY_MOVE (yyla));

Then there follows code that gets a new yyla.value:
    // Read a lookahead token.
    if (yyla.empty ())

However, if this condition is false, there is a second std::move at:
    // Shift the lookahead token.
    yypush_ ("Shifting", state_type (yyn), YY_MOVE (yyla));
    goto yynewstate;

reply via email to

[Prev in Thread] Current Thread [Next in Thread]