x86 64 bit function argument bug?,..

Falk Hueffner falk.hueffner@student.uni-tuebingen.de
Sun May 4 16:55:00 GMT 2003


Stephen Biggs <xyzzy@hotpop.com> writes:

> #include <stdio.h>
> void f(unsigned int *p) {
>     printf("%x\n", *p);
> }
> void g(unsigned long long x,...) {
>     f((unsigned int *)(((char *)&x)+sizeof(x)));
> }
> int main(void) {
>     g(0x1122334455667788ULL,0x11223344U);
> }
> 
> ... you would get bogus results, if not a crash, because it is taking
> the address of the quantity on the stack previous to the call instead of
> the current argument list.

But this is clearly invalid C, and I'm pretty certain we don't want to
support this as an extension, either. So I guess you're out of luck.

-- 
	Falk



More information about the Gcc mailing list