[PATCH] Avoid infinite loop with duplicate anonymous union fields

Bogdan Harjoc harjoc@gmail.com
Tue Jul 31 09:56:00 GMT 2018


With fresh git sources and contrib/gcc_update the tests pass:

=== gcc Summary ===

# of expected passes 133500
# of expected failures 422
# of unsupported tests 2104

gcc-build/gcc/xgcc  version 9.0.0 20180730 (experimental) (GCC)

I wasn't able to reduce the input to avoid including <time.h> and as
it only reproduces without -save-temps, it's not clear how to write a
testcase for this one.

On Fri, Jul 27, 2018 at 8:01 PM, Joseph Myers <joseph@codesourcery.com> wrote:
> On Fri, 27 Jul 2018, Bogdan Harjoc wrote:
>
>> 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.
>
> The patch should also add a testcase to the testsuite (which fails before
> and passes after the patch).
>
>> 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)
>
> You should use contrib/gcc_update --touch to get timestamps in the right
> order when checking out.  This failure is a symptom of badly ordered
> timestamps.
>
> --
> Joseph S. Myers
> joseph@codesourcery.com



More information about the Gcc-patches mailing list