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 44449
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=44449&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 <some header> 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.

Reply via email to