mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-09 12:23:04 +00:00
c++: beware of short ranges for state numbers
Now that we use small integral types, possibly unsigned (e.g., unsigned char), to store state numbers, using -1 to denote an empty state (i.e., a state that stores no semantical value) is very dangerous: it will be confused with state 255, which might be non-empty. Rather than allocating a larger range of state numbers to keep the empty-state apart, let's use the number of a state known to store no value. The initial state, numbered 0, seems to fit perfectly the job. Reported by Frank Heckenbach. https://lists.gnu.org/archive/html/bug-bison/2019-11/msg00016.html * data/skeletons/lalr1.cc (empty_state): Be 0.
This commit is contained in:
@@ -335,7 +335,8 @@ m4_define([b4_shared_declarations],
|
||||
symbol_number_type type_get () const YY_NOEXCEPT;
|
||||
|
||||
/// The state number used to denote an empty symbol.
|
||||
enum { empty_state = -1 };
|
||||
/// We use the initial state, as it does not have a value.
|
||||
enum { empty_state = 0 };
|
||||
|
||||
/// The state.
|
||||
/// \a empty when empty.
|
||||
|
||||
Reference in New Issue
Block a user