stdarg x86_64 problems...
Jonathan M Davis
jmdavisProg at gmx.com
Thu Jul 12 02:28:53 PDT 2012
On Thursday, July 12, 2012 11:12:08 John Colvin wrote:
> When I compile the following code with -m32 and -m64 i get a
> totally different result, the documentation suggests that they
> should be the same...
>
> import core.stdc.stdarg, std.stdio;
>
> void main() {
> foo(0,5,4,3);
> }
>
> void foo(int dummy, ...) {
> va_list ap;
>
> for(int i; i<10; ++i) {
> version(X86_64) {
> va_start(ap, __va_argsave);
> }
> else version(X86) {
> va_start(ap, dummy);
> }
> else
> static assert(false, "Unsupported platform");
>
> int tmp;
> va_arg!(int)(ap,tmp);
> writeln(ap," ", tmp);
> }
> }
>
> when compiled with -m32 I get:
>
> FF960278 5
> FF960278 5
> FF960278 5
> FF960278 5
> FF960278 5
>
> and with -m64 I get:
>
> 7FFFCDF941D0 5
> 7FFFCDF941D0 4
> 7FFFCDF941D0 3
> 7FFFCDF941D0 38
> 7FFFCDF941D0 -839302560
>
> (the end stuff is garbage, different every time)
>
> I'm uncertain, even after looking over the stdarg src, why this
> would happen. The correct output is all 5s obviously.
I expect that it's a bug. Please report it: http://d.puremagic.com/issues
64-bit support is relatively new, and while it works well overall, there _are_
a few serious bugs with it - particularly with regards to interacting with C
(e.g. http://d.puremagic.com/issues/show_bug.cgi?id=5570 ). It's being worked
on, but it's obviously still buggy in the interim, and it sounds like you
found another bug with it.
- Jonathan M Davis
More information about the Digitalmars-d-learn
mailing list