public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/34001]  New: Incorrect __attribute__ fastcall behavior
@ 2007-11-05 23:40 zia at aracnet dot com
  2007-11-05 23:58 ` [Bug target/34001] " pinskia at gcc dot gnu dot org
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: zia at aracnet dot com @ 2007-11-05 23:40 UTC (permalink / raw)
  To: gcc-bugs

4byte structures that are passed as parameters to a fastcall routine will get
passed as registers. This does not match the original fastcall convention,
which passes such structures on the stack.

Compiling this code:
#include <stdio.h>

typedef struct {
  int a;
} my_struct;

int __attribute__((fastcall)) foo(my_struct s, int b)
{
  return s.a + b;
}


main()
{
  my_struct ss;
  ss.a = 1;
  printf("\nfoo = %d.\n",foo(ss,2));
}

Results in:
.
.
        movl    $1, -12(%ebp)
        movl    -12(%ebp), %ecx
        movl    $2, %edx
        call    _foo
.
.
and
.
.
.globl _foo
_foo:
        pushl   %ebp
        movl    %esp, %ebp
        subl    $24, %esp
        movl    %ecx, -12(%ebp)
        movl    %edx, -16(%ebp)
        movl    -12(%ebp), %eax
        addl    -16(%ebp), %eax
        leave
        ret

With GCC.

Using other compilers that support fastcall will pass the struct value on the
stack.


-- 
           Summary: Incorrect __attribute__ fastcall behavior
           Product: gcc
           Version: 4.0.1
            Status: UNCONFIRMED
          Severity: major
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: zia at aracnet dot com


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


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2007-11-28  1:25 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-11-05 23:40 [Bug c/34001] New: Incorrect __attribute__ fastcall behavior zia at aracnet dot com
2007-11-05 23:58 ` [Bug target/34001] " pinskia at gcc dot gnu dot org
2007-11-08 17:12 ` hjl at lucon dot org
2007-11-09 16:55 ` hjl at lucon dot org
2007-11-09 17:34 ` hjl at lucon dot org
2007-11-12  3:27 ` [Bug target/34001] Incorrect x86 " hjl at lucon dot org
2007-11-16  4:52 ` hjl at lucon dot org
2007-11-26 23:19 ` hjl at lucon dot org
2007-11-27  2:36 ` hjl at lucon dot org
2007-11-28  1:20 ` hjl at gcc dot gnu dot org
2007-11-28  1:25 ` hjl at lucon dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).