This is the mail archive of the
gcc-prs@gcc.gnu.org
mailing list for the GCC project.
c/9890: __builtin_apply generates incorrect reference to arguments
- From: zandy at cs dot wisc dot edu
- To: gcc-gnats at gcc dot gnu dot org
- Cc: gquinn at cs dot wisc dot edu
- Date: 28 Feb 2003 20:21:58 -0000
- Subject: c/9890: __builtin_apply generates incorrect reference to arguments
- Reply-to: zandy at cs dot wisc dot edu
>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;
}