mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-09 12:23:04 +00:00
glr2.cc: fix glr_stack_item::setState
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/glr2.cc (glr_stack_item::setState): Build the state, don't just copy it.
This commit is contained in:
@@ -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 ()
|
||||
|
||||
Reference in New Issue
Block a user