c++: avoid GCC 8 warnings

GCC 8 issues warnings whose root cause was a bit hard to find.

    calc.cc: In member function 'virtual int yy::parser::parse()':
    calc.cc:810:18: warning: '*((void*)&<anonymous> +8)' may be used uninitialized in this function [-Wmaybe-uninitialized]
         , location (l)
                      ^
    calc.cc: In member function 'void yy::parser::yypush_(const char*, yy::parser::stack_symbol_type&)':
    calc.cc:810:18: warning: '*((void*)&<anonymous> +8)' may be used uninitialized in this function [-Wmaybe-uninitialized]
         , location (l)
                      ^
    calc.cc: In member function 'void yy::parser::yypush_(const char*, yy::parser::state_type, yy::parser::symbol_type&)':
    calc.cc:810:18: warning: '*((void*)&<anonymous> +8)' may be used uninitialized in this function [-Wmaybe-uninitialized]
         , location (l)
                      ^

The problem is with locations that don't have a constructor, such as
Span (in calc.cc) which is POD.  It is POD on purpose: so that we can
use that structure to test glr.cc which cannot use non POD in its
(C) stacks.

* data/c++.m4 (basic_symbol): Also ensure that 'location' is
initialized.
This commit is contained in:
Akim Demaille
2018-08-15 18:35:46 +02:00
parent 45ca5043ce
commit bd07c76b0a
2 changed files with 3 additions and 2 deletions

View File

@@ -296,7 +296,8 @@ m4_define([b4_public_types_define],
// basic_symbol.
template <typename Base>
]b4_parser_class_name[::basic_symbol<Base>::basic_symbol ()
]b4_parser_class_name[::basic_symbol<Base>::basic_symbol ()]b4_locations_if([
: location ()])[
{}
template <typename Base>

2
gnulib

Submodule gnulib updated: 8635df0ac8...dd1a129ef6