digitalmars.D.learn - stdarg x86_64 problems...
- John Colvin (40/40) Jul 12 2012 When I compile the following code with -m32 and -m64 i get a
- Jonathan M Davis (8/57) Jul 12 2012 I expect that it's a bug. Please report it: http://d.puremagic.com/issue...
- Don Clugston (2/40) Jul 12 2012 Known bug, already fixed in git for a couple of months.
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.
Jul 12 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
Jul 12 2012
On 12/07/12 11:12, 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.Known bug, already fixed in git for a couple of months.
Jul 12 2012