x86 64 bit function argument bug?

Daniel Jacobowitz drow@mvista.com
Sun May 4 16:11:00 GMT 2003


On Sun, May 04, 2003 at 06:02:32PM +0200, Falk Hueffner wrote:
> Stephen Biggs <xyzzy@hotpop.com> writes:
> 
> > On Sun, 2003-05-04 at 11:54, Falk Hueffner wrote:
> > > Stephen Biggs <xyzzy@hotpop.com> writes:
> > > > I want to take an address of an argument and dereference it to
> > > > access the value that is passed to a function on the stack.
> > > 
> > > That should work just fine. If it doesn't, it's a bug.
> > 
> > Ah, now we understand each other.  I am saying that the x86 behavior
> > for 64 bit value arguments is a bug.
> 
> Maybe you can provide a test case without undefined behaviour that
> shows this?
> 
> #include <stdio.h>
> void f(unsigned long long *p) {
>     printf("%llx\n", *p);
> }
> void g(unsigned long long x) {
>     f(&x);
> }
> int main(void) {
>     g(0x1122334455667788ULL);
> }
> 
> works for me.
> 
> > > > Basically I am trying to do varargs/stdarg without using varargs or
> > > > any built-in functions.
> > > 
> > > That is impossible to do portably.
> > 
> > Granted.  I would be satisfied with it working in GCC, and it does on
> > the x86 except for 64 bit values.
> 
> I'm pretty sure that is still impossible, unless you also restrict
> yourself to the x86 architecture.

I'm pretty sure it's impossible to do even on x86.  The problem
Stephen's describing isn't a bug; the home of the 64-bit argument
happens to be in a local stack slot rather than in the argument save
area, that's all.

Stephen, what you haven't explained is why you want to do this
complicated varargs-like hack without using varargs.  Could you give an
example of what you're trying to do?


-- 
Daniel Jacobowitz
MontaVista Software                         Debian GNU/Linux Developer



More information about the Gcc mailing list