public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/40718]  New: Invalid code produced with -foptimize-sibling-calls
@ 2009-07-11  0:06 d dot g dot gorbachev at gmail dot com
  2009-08-22 12:09 ` [Bug middle-end/40718] " slyfox at inbox dot ru
                   ` (15 more replies)
  0 siblings, 16 replies; 17+ messages in thread
From: d dot g dot gorbachev at gmail dot com @ 2009-07-11  0:06 UTC (permalink / raw)
  To: gcc-bugs

The following program will fail.

gcc -S -O1 -foptimize-sibling-calls bug.c

bug.c:
============================================
#define stdcall __attribute__((__stdcall__))

struct S {
    void (stdcall *f)(struct S *);
    int i;
};

void stdcall foo(struct S *s)
{
    s->i++;
}

void stdcall bar(struct S *s)
{
    foo(s);
    s->f(s);
}

int main(void)
{
    struct S s = { foo, 0 };
    bar(&s);
}
============================================

This is what the compiler produces:

bar:
        pushl   %ebp
        movl    %esp, %ebp
        pushl   %ebx
        subl    $20, %esp
        movl    8(%ebp), %ebx
        movl    %ebx, (%esp)
        call    foo
        subl    $4, %esp
        movl    %ebx, 8(%ebp)
        movl    -4(%ebp), %ebx
        leave
        jmp     *(%ebx)


-- 
           Summary: Invalid code produced with -foptimize-sibling-calls
           Product: gcc
           Version: 4.5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: d dot g dot gorbachev at gmail dot com
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


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


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

end of thread, other threads:[~2009-08-29 10:26 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-07-11  0:06 [Bug middle-end/40718] New: Invalid code produced with -foptimize-sibling-calls d dot g dot gorbachev at gmail dot com
2009-08-22 12:09 ` [Bug middle-end/40718] " slyfox at inbox dot ru
2009-08-22 13:38 ` [Bug target/40718] " ubizjak at gmail dot com
2009-08-22 13:43 ` ubizjak at gmail dot com
2009-08-22 13:51 ` ubizjak at gmail dot com
2009-08-22 18:38 ` slyfox at inbox dot ru
2009-08-23  9:09 ` ubizjak at gmail dot com
2009-08-23  9:46 ` uros at gcc dot gnu dot org
2009-08-23 11:12 ` slyfox at inbox dot ru
2009-08-23 11:41 ` ubizjak at gmail dot com
2009-08-23 11:58 ` ubizjak at gmail dot com
2009-08-23 12:08 ` ubizjak at gmail dot com
2009-08-23 12:14 ` uros at gcc dot gnu dot org
2009-08-23 12:38 ` uros at gcc dot gnu dot org
2009-08-23 13:04 ` uros at gcc dot gnu dot org
2009-08-23 13:04 ` ubizjak at gmail dot com
2009-08-29 10:26 ` slyfox at inbox dot ru

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).