c++: fix GCC8 warnings about uninitialized values

In 0931d14728 I removed too many
initializations from some ctors: some were not about base ctors, but
about member variables.  In fact, more of them were missing to please
GCC 8.

While at it, generate more natural code for C++ without variant:
instead of

    template <typename Base>
    parser::basic_symbol<Base>::basic_symbol (const basic_symbol& other)
      : Base (other)
      , value ()
    {
      value = other.value
    }

generate

    template <typename Base>
    parser::basic_symbol<Base>::basic_symbol (const basic_symbol& other)
      : Base (other)
      , value (other.value)
    {}

* data/c++.m4 (basic_symbol::basic_symbol): Always initialize 'value',
it might be a POD without a ctor.
* data/lalr1.cc (stack_symbol_type::stack_symbol_type): Likewise.
* data/variant.hh (variant::variant): Default initialize the buffer too.
This commit is contained in:
Akim Demaille
2018-08-15 15:19:25 +02:00
parent 45b9d97b54
commit 1113522acb
3 changed files with 17 additions and 15 deletions

View File

@@ -574,11 +574,10 @@ m4_if(b4_prefix, [yy], [],
{}
]b4_parser_class_name[::stack_symbol_type::stack_symbol_type (state_type s, symbol_type& that)
: super_type (s]b4_locations_if([, that.location])[)
{
]b4_variant_if([b4_symbol_variant([that.type_get ()],
[value], [move], [that.value])],
[[value = that.value;]])[
: super_type (s]b4_variant_if([], [, that.value])[]b4_locations_if([, that.location])[)
{]b4_variant_if([
b4_symbol_variant([that.type_get ()],
[value], [move], [that.value])])[
// that is emptied.
that.type = empty_symbol;
}