bug-bison
[Top][All Lists]
Advanced

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

YY_MOVE defined as std:: move instead of std::forward for C++14 and late


From: Ben Griffin
Subject: YY_MOVE defined as std:: move instead of std::forward for C++14 and later
Date: Tue, 30 Nov 2021 12:27:28 +0000

Static analysis reports 

    /// Construct and fill.
    template <typename T>
    value_type (YY_RVREF (T) t)
      : yytypeid_ (&typeid (T))
    {
      YY_ASSERT (sizeof (T) <= size);
      new (yyas_<T> ()) T (YY_MOVE (t));  // <<--- HERE
    }

"Forwarding reference passed to std::move(), which may unexpectedly cause 
lvalues to be moved; use std::forward() instead”

On y.tab.h line 75, I see:

#if 201103L <= YY_CPLUSPLUS
# define YY_MOVE           std::move


Maybe this could be

#if 201103L <= YY_CPLUSPLUS
#if 201402L <= YY_CPLUSPLUS
# define YY_MOVE           std::forward
#else
# define YY_MOVE           std:: move


I realise that these are well controlled private implementations, but for naive 
programmers like myself, it causes a mild concern to see a static analysis 
report.

Best regards
        Ben.

Attachment: smime.p7s
Description: S/MIME cryptographic signature


reply via email to

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