$ cat test.d import std.string; struct S { string toString() { return "foo"; } } void main() { format("%s", S()); } $ gdc test.d $ ./a.out std.format.FormatException@../../../gcc-4.8-20120701/libphobos/std/format.d(4748): cannot portably format a struct on this target ---------------- ./a.out() [0x43aa10] ./a.out() [0x4238c3] ./a.out() [0x4239b1] ./a.out() [0x402502] ./a.out() [0x405be1] ./a.out() [0x40608d] ./a.out() [0x406140] ./a.out() [0x40608d] ./a.out() [0x40666c] /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xed) [0x7f29b9bb430d] ./a.out() [0x402385] ---------------- This program should print "foo".
Documentation on known differences should be updated. DMD on 64bit has a runtime library implementation that retrieves the next variadic argument based on it's TypeInfo and it's tsize(). eg: auto va = va_arg(ap, ti); GDC uses it's GCC's built-in VA_ARG_EXPR, which depends on the type being known at compile time in order to work. eg: auto va = va_arg!(Foo)(ap); There is no way around this other than implementing a new runtime function which does a similar job that DMD's implementation does, but have it specific for the way GDC passes variadic arguments to the callee.
Implements the remainder va_arg templates missing in GDC runtime. https://github.com/D-Programming-GDC/GDC/commit/f039c099235636cf64242c21e572fca6c0a5952e Harmonises doFormat implementation in GDC phobos with upstream so testcase passes. https://github.com/D-Programming-GDC/GDC/commit/185320fa4ce894fd6a60a1cd398ef7659422924b
Can we close this bug report?
If your happy. Closed.