[Bug target/58496] New: bug in win64 calling standard

mikulas at artax dot karlin.mff.cuni.cz gcc-bugzilla@gcc.gnu.org
Sat Sep 21 19:59:00 GMT 2013


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

            Bug ID: 58496
           Summary: bug in win64 calling standard
           Product: gcc
           Version: 4.8.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: mikulas at artax dot karlin.mff.cuni.cz
              Host: x86_64-pc-cygwin
            Target: x86_64-pc-cygwin
             Build: x86_64-pc-cygwin

Windows on x86-64 uses a different calling standard than Linux. On Windows x64
ABI, integer arguments are passed in RCX, RDX, R8 and R9. Floating point
arguments are passed in XMM0, XMM1, XMM2, XMM3. For variable-argument
functions,
floating point arguments must be passed in both integer register as well as XMM
register.

If the function was declared with prototype without argument list (such as
"int printf()"), we don't know if the function has fixed or variable argument
list
and thus we must pass floating point arguments in both integer and XMM
registers.

There comes the bug: this program doesn't print the correct value on Cygwin64
with gcc-4.8.1 because gcc passes the variable 1.2 in XMM1. gcc should pass the
value in both XMM1 and RDX, because the prototype doesn't tell if printf has
variable-argument list or not.

int printf();

int main(void)
{
        printf("%f\n", 1.2);
        return 0;
}



More information about the Gcc-bugs mailing list