This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: [PATCH] Fix aliasing miscompilation

>>>>> "Jakub" == Jakub Jelinek <> 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> 	* 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

What would be safe would be to reset TYPE_ALIAS_SET to -1 at that
point, I think.

Mark Mitchell         
CodeSourcery, LLC     

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]