[PATCH] Avoid infinite loop with duplicate anonymous union fields

Bogdan Harjoc harjoc@gmail.com
Fri Jul 27 10:27:00 GMT 2018


(this patch is already uploaded to
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=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.

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

The patch falls back to iterating via DECL_CHAIN if there was an error
earlier during compilation.

I ran the gcc testsuite with the result (the FAIL seems unrelated to the patch):

FAIL: gcc.dg/cpp/_Pragma3.c (test for excess errors)

                === gcc Summary ===

# of expected passes            135094
# of unexpected failures        1
# of expected failures          398
# of unsupported tests          2140
gcc-build/gcc/xgcc  version 8.0.1 20180424 (experimental) (GCC)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: avoid-loop-with-duplicate-union-field.patch
Type: text/x-patch
Size: 1031 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20180727/15b50f61/attachment.bin>


More information about the Gcc-patches mailing list