[Bug c/12329] New: x86: local function declared with attribute((regparm(3))) gets corrupted parent frame pointer

jbeulich at novell dot com gcc-bugzilla@gcc.gnu.org
Thu Sep 18 15:06:00 GMT 2003


PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

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

           Summary: x86: local function declared with
                    attribute((regparm(3))) gets corrupted parent frame
                    pointer
           Product: gcc
           Version: 3.3.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: jbeulich at novell dot com
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu

Since the parent function's frame pointer is passed in ECX, that register should
not be available for argument passing. However, the third parameter is assigned
to ECX, and thus the callee's assumption of (also) finding the frame pointer
there breaks.

int test(int i) {
	static int __attribute__((__regparm__(3))) stest(int j, int k, int l) {
		return i + j + k + l;
	}
	return stest(i, i, i) * i;
}



More information about the Gcc-bugs mailing list