public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "d dot g dot gorbachev at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug middle-end/40718]  New: Invalid code produced with -foptimize-sibling-calls
Date: Sat, 11 Jul 2009 00:06:00 -0000	[thread overview]
Message-ID: <bug-40718-16926@http.gcc.gnu.org/bugzilla/> (raw)

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


             reply	other threads:[~2009-07-11  0:06 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-07-11  0:06 d dot g dot gorbachev at gmail dot com [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-40718-16926@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).