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

--- Comment #3 from Joseph S. Myers <jsm28 at gcc dot gnu.org> ---
Author: jsm28
Date: Fri Aug  3 15:25:35 2018
New Revision: 263294

URL: https://gcc.gnu.org/viewcvs?rev=263294&root=gcc&view=rev
Log:
Avoid infinite loop with duplicate anonymous union fields (PR c/86690).

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.

2018-08-03  Bogdan Harjoc  <har...@gmail.com>

        PR c/86690
gcc/c:
        * c-typeck.c (lookup_field): Do not use TYPE_LANG_SPECIFIC after
        errors.

gcc/testsuite:
        * gcc.dg/union-duplicate-field.c: New test.

Added:
    trunk/gcc/testsuite/gcc.dg/union-duplicate-field.c
Modified:
    trunk/gcc/c/ChangeLog
    trunk/gcc/c/c-typeck.c
    trunk/gcc/testsuite/ChangeLog

Reply via email to