[Top][All Lists]

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

[PATCH 3/4] fix glr_stack_item::setState

From: Akim Demaille
Subject: [PATCH 3/4] fix glr_stack_item::setState
Date: Fri, 18 Dec 2020 07:42:03 +0100

A glr_stack_item has "raw" memory to store either a glr_state or a
semantic_option.  glr_stack_item::setState stores a state using a copy
assignment.  However, this is more like a construction: we are
starting from "raw" memory, so use the placement new operator instead.
While it probably makes no difference when parse.assert is disabled,
it does make one when it is: the constructor properly initialize the
magic number, the assignment does not.  So without these changes, the
next commit (which stores genuine objects in semantic values) fails
tests 712 and 730 because of incorrect magic numbers.

* data/skeletons/ (glr_stack_item::setState): Build the state,
don't just copy it.
 data/skeletons/ | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/data/skeletons/ b/data/skeletons/
index 84b0d723..e6d4717d 100644
--- a/data/skeletons/
+++ b/data/skeletons/
@@ -1235,8 +1235,7 @@ public:
     // is in unused state (in the list of free items), when parse.assert
     // is set.
     is_state_ = true;
-    void *yyp = raw_;
-    static_cast<glr_state*> (yyp)->copyFrom (state);
+    new (&raw_) glr_state (state);
   glr_state& getState ()

reply via email to

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