This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Avoid infinite loop with duplicate anonymous union fields
- From: Joseph Myers <joseph at codesourcery dot com>
- To: Bogdan Harjoc <harjoc at gmail dot com>
- Cc: <gcc-patches at gcc dot gnu dot org>
- Date: Fri, 27 Jul 2018 17:01:59 +0000
- Subject: Re: [PATCH] Avoid infinite loop with duplicate anonymous union fields
- References: <CAF4+tmoDjG6qb9bo8CRaszsv7wfRctk6gfNzxTC9WvXFN3zvcg@mail.gmail.com>
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