This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Fix aliasing miscompilation
- To: jakub at redhat dot com
- Subject: Re: [PATCH] Fix aliasing miscompilation
- From: Mark Mitchell <mark at codesourcery dot com>
- Date: Tue, 24 Oct 2000 08:13:57 -0700
- Cc: gcc-patches at gcc dot gnu dot org
- Organization: CodeSourcery, LLC
- References: <20001024134442.D12422@sunsite.ms.mff.cuni.cz>
>>>>> "Jakub" == Jakub Jelinek <jakub@redhat.com> writes:
Jakub> Hi!
Jakub> The following testcase is miscompiled with -O2 on i386. The
Jakub> reason is that when the __restrict keyword is applied to
Jakub> the pointer to incomplete struct a, get_alias_set sets up
Jakub> alias for struct a as whole but record_component_aliases is
Jakub> never called on that type once it is layout out fully (the
Jakub> testcase does not fail even without this patch if baz
Jakub> prototype is moved after struct a full declaration or if
Jakub> the __restrict keyword is removed from baz prototype). The
Jakub> patch below seems to fix it. I'm not testing
Jakub> flag_strict_aliasing because then the alias set is either 0
Jakub> or -1. Ok to commit?
Jakub> 2000-10-24 Jakub Jelinek <jakub@redhat.com>
Jakub> * stor-layout.c (layout_type): Call
Jakub> record_component_aliases if TYPE_ALIAS_SET was already set
Jakub> on the incomplete type.
There was historical discussion about this. Your patch is incorrect
because some front-ends (C++) continue to modify the type after
layout_type.
What would be safe would be to reset TYPE_ALIAS_SET to -1 at that
point, I think.
--
Mark Mitchell mark@codesourcery.com
CodeSourcery, LLC http://www.codesourcery.com