public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
From: zandy@cs.wisc.edu
To: gcc-gnats@gcc.gnu.org
Cc: gquinn@cs.wisc.edu
Subject: c/9890: __builtin_apply generates incorrect reference to arguments
Date: Fri, 28 Feb 2003 20:26:00 -0000	[thread overview]
Message-ID: <20030228202158.17017.qmail@sources.redhat.com> (raw)


>Number:         9890
>Category:       c
>Synopsis:       __builtin_apply generates incorrect reference to arguments
>Confidential:   no
>Severity:       critical
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Feb 28 20:26:01 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator:     vic zandy
>Release:        gcc 3.2.2
>Organization:
>Environment:
linux 2.4.18 i686
intel pentium 4 2.0GHz
>Description:
_builtin_apply passes incorrect arguments
to the function it calls.
>How-To-Repeat:
gcc -o myfile myfile.c
./myfile
observe that output is NOT "foo(1,2)" as it
should be.
note that the right thing happens if
assert(0) in docall is removed.
i have a more complicated example that
exhibits the misbehavior but does not
contain code after the builtin_return,
available upon request
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: text/plain; name="myfile.c"
Content-Disposition: inline; filename="myfile.c"

#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <dlfcn.h>

int
foo(int x, int y)
{
	fprintf(stderr, "foo(%d,%d)\n", x, y);
	return 0;
}

int
docall(int x, int y)
{
	void *args, *result;
	void *f;

	f = (void*)foo;
	args = __builtin_apply_args();
	result = __builtin_apply((void(*)()) f,
				 args, 6*sizeof(int));
	__builtin_return(result);
	assert(0);
}

int
main(int argc, char *argv[])
{
	int rv;
	rv = docall(1, 2);
	return 0;
}


                 reply	other threads:[~2003-02-28 20:26 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20030228202158.17017.qmail@sources.redhat.com \
    --to=zandy@cs.wisc.edu \
    --cc=gcc-gnats@gcc.gnu.org \
    --cc=gquinn@cs.wisc.edu \
    /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).