Bug 26294 - va_list passing breaks on x86-64 only
Summary: va_list passing breaks on x86-64 only
Status: RESOLVED DUPLICATE of bug 14557
Alias: None
Product: gcc
Classification: Unclassified
Component: c (show other bugs)
Version: 3.4.4
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-02-15 03:19 UTC by Ian Gulliver
Modified: 2006-02-15 03:26 UTC (History)
5 users (show)

See Also:
Host: x86_64-pc-linux-gnu
Target: x86_64-pc-linux-gnu
Build: x86_64-pc-linux-gnu
Known to work:
Known to fail:
Last reconfirmed:


Attachments
test.c (201 bytes, text/plain)
2006-02-15 03:21 UTC, Ian Gulliver
Details
test.i (3.59 KB, text/plain)
2006-02-15 03:21 UTC, Ian Gulliver
Details
test.s (1.00 KB, text/plain)
2006-02-15 03:21 UTC, Ian Gulliver
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Ian Gulliver 2006-02-15 03:19:49 UTC
The following works on i386, sparc32 and sparc64, but produces a compiler warning on x86-64, then prints garbage and crashses when run:

---------------------------
#include <stdarg.h>
#include <stdio.h>

void func3(va_list *ap) {
        int test = va_arg(*ap,int);
        fprintf(stderr,"%d\n",test);
}

void func2(va_list ap) {
        func3(&ap);
}

void func1(int start, ...) {
        va_list ap;

        va_start(ap,start);

        func2(ap);

        va_end(ap);
}

int main() {
        fprintf(stderr,"This should print 1:\n");
        func1(2,1);
        return 0;
}
---------------------------
test.c: In function `func2':
test.c:10: warning: passing arg 1 of `func3' from incompatible pointer type
---------------------------
This should print 1:
-7609280
Segmentation fault
Comment 1 Ian Gulliver 2006-02-15 03:21:07 UTC
Created attachment 10851 [details]
test.c
Comment 2 Ian Gulliver 2006-02-15 03:21:27 UTC
Created attachment 10852 [details]
test.i
Comment 3 Ian Gulliver 2006-02-15 03:21:42 UTC
Created attachment 10853 [details]
test.s
Comment 4 Andrew Pinski 2006-02-15 03:26:14 UTC
Your code is invalid for x86_64 (and ppc-linux).
This is a dup of bug 14557.

*** This bug has been marked as a duplicate of 14557 ***