https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68795

Nick Clifton <nickc at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |nickc at redhat dot com

--- Comment #1 from Nick Clifton <nickc at redhat dot com> ---
Created attachment 37066
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=37066&action=edit
Always set a location for the closing parenthesis in
cp_parser_parenthesized_expression_list

Hi Guys,

  This patch fixes the problem, although it may not be the best way to resolve
the bug.

  The problem is that cp/parser.c:cp_parser_postfix_expression assumes that
cp_parser_parenthesized_expression_list always sets a value for the location of
the closing parenthesis, even if there is an error in the parsing.  This
location is then passed to make_location and on down until it is eventually
used in libcpp/line-map.c:location_adhoc_data_hash.  This is where valgrind
detects the unitinialised use.  (Although it reports the location as being
somewhere else).

  The uploaded patch makes cp_parser_parenthesized_expression_list set a
default, unknown, location for the closing parenthesis first, and then later on
it can be overridden with the correct location if one is found.  This means
that all callers of cp_parser_parenthesized_expression_list can now assume that
the closing parenthesis location will be set.  An alternative patch would be to
make cp_parser_parenthesized_expression_list set the location to unknown only
if it cannot find the location, or to just modify cp_parser_postfix_expression
so that it initialises the location to unknown before calling
cp_parser_parenthesized_expression_list.

Cheers
  Nick

Reply via email to