[Bug c/86690] New: [PATCH] Duplicate field in anonymous union causes infinite loop

2018-07-26 Thread harjoc at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86690

Bug ID: 86690
   Summary: [PATCH] Duplicate field in anonymous union causes
infinite loop
   Product: gcc
   Version: 8.2.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c
  Assignee: unassigned at gcc dot gnu.org
  Reporter: harjoc at gmail dot com
  Target Milestone: ---

Created attachment 9
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=9&action=edit
Test file

If a struct contains an anonymous union and both have a field with the same
name, detect_field_duplicates_hash() will replace one of them with NULL. If
compilation doesn't stop immediately, it may later call lookup_field() on the
union, which falsely assumes the union's LANG_SPECIFIC array is sorted, and may
loop indefinitely because of this. 

Attached testcase hangs without -save-temps, doesn't hang with -save-temps. It
only reproduces if there is an #include  for some reason.

Reproduced on amd64 since gcc-5, on ubuntu-18.04 and gentoo. 

Attached patch falls back to iterate via DECL_CHAIN if there was an error
earlier during compilation.

[Bug c/86690] [PATCH] Duplicate field in anonymous union causes infinite loop

2018-07-26 Thread harjoc at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86690

--- Comment #1 from Bogdan Harjoc  ---
Created attachment 44450
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=44450&action=edit
Proposed patch