On i386, combining -regparm=3 with nested functions results in %ecx (holding
the third function parameter because of -regparm=3) being overwritten with a
temporary pointer used by GCC to implement the nested function call.

GNU GRUB has had a workaround (disabling -regparm in a case-by-case basis) to
this bug for a long while.  It's only been brought up to me recently that we
had this problem (I'm one of the GRUB maintainers).

One of the GRUB developers (Bean) produced a test case.  I'm attaching it here.


-- 
           Summary: %ecx corruption when combining -regparm=3 with nested
                    functions
           Product: gcc
           Version: 4.5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: rmh at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41246

Reply via email to