Bug 443583

Summary: gcc produces broken code when -mregparm=3
Product: [Fedora] Fedora Reporter: Simon Wilkinson <simon>
Component: gccAssignee: Jakub Jelinek <jakub>
Status: CLOSED CURRENTRELEASE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: high Docs Contact:
Priority: high    
Version: 9CC: Axel.Thimm, nalin
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: 4.3.0-8 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2008-06-06 12:42:08 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Simon Wilkinson 2008-04-22 12:08:04 UTC
Description of problem:

gcc 4.3.0 as shipped in Fedora 9 pre produces broken code when building un-protoyped functions with 
-mregparm=3

Version-Release number of selected component (if applicable):4.3.0-7


How reproducible:

Build the following test program, with -mregparm=3

extern int printf (const char *, ...) __attribute__ ((regparm(0)));

static int test();

int main(int argc, char **argv) {

  test(0,1,2,3,4,5,6,7);
}

static int test(int a, int b, int c, int d, int e, int f, int g, int h) {
  if (a != 0 || b != 1 || c != 2) {
    printf("Wrong: Got (%p, %p, %p, %p, %p, %p, %p, %p)", a, b, c, d, e, f, g, h);
  }

  return 1;
}

Steps to Reproduce:
1. Compile the above program with -mregparm=3
2. Run it
  
Actual results:

Program produces output similar to:

Wrong: Got (0x1, 0xbfc96430, 0xbfc96410, (nil), 0x1, 0x2, 0x3, 0x4)

Expected results:

Program produces no output.

Additional info:

It looks like the calling convention is getting screwed up when regparm is being used with defintions 
that aren't fully prototyped (adding a complete prototype for test will fix this problem).

Comment 1 Simon Wilkinson 2008-04-23 11:42:44 UTC
Do you think this will be fixed before the final release of Fedora 9?

Comment 2 Bug Zapper 2008-05-14 09:56:09 UTC
Changing version to '9' as part of upcoming Fedora 9 GA.
More information and reason for this action is here:
http://fedoraproject.org/wiki/BugZappers/HouseKeeping

Comment 3 Jakub Jelinek 2008-06-06 12:42:08 UTC
This was fixed in 4.3.0-8.