https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90130
Bug ID: 90130 Summary: gdc.test/runnable/test12.d FAILs Product: gcc Version: 9.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: d Assignee: ibuclaw at gdcproject dot org Reporter: ro at gcc dot gnu.org Target Milestone: --- Target: sparc*-*-solaris2.11 The gdc.test/runnable/test12.d test FAILs on Solaris 11/SPARC with Robin's big-endian patches applied: FAIL: gdc.test/runnable/test12.d -finline-functions -funittest -g execution test core.exception.AssertError@runnable/test12.d(630): Assertion failure ---------------- /vol/gcc/src/hg/trunk/solaris/libphobos/libdruntime/gcc/deh.d:499 _d_throw [0x1001bb58f] /vol/gcc/src/hg/trunk/solaris/libphobos/libdruntime/core/exception.d:441 onAssertError [0x1001b880b] /vol/gcc/src/hg/trunk/solaris/libphobos/libdruntime/core/exception.d:641 _d_assert [0x1001b8e13] runnable/test12.d:630 int test12.hoge(test12.S29) [0x100112ddf] runnable/test12.d:642 void test12.test29() [0x100112e4b] runnable/test12.d:1220 _Dmain [0x100114fc7] Thread 2 hit Breakpoint 1, test12.hoge(test12.S29) (s=...) at runnable/test12.d:624 624 char[10] b; (gdb) n 625 printf("%x\n", s); (gdb) p s $1 = {a = 1 '\001', b = 2 '\002', c = 3 '\003', d = 4 '\004'} (gdb) n ffbfe4d0 626 sprintf(b.ptr, "%x", s); (gdb) n 630 assert(b[0 .. 7] == "1020304"); (gdb) p b $2 = "ffbfe4d0\000\377" This ia another call-by-value vs. call-by-reference issue: the test assumes that passing a small struct (struct S29) happens by value. While this is true in some ABIs, it's certainly not in others (like the 32-bit SPARC one) where even small structs are passed by reference. PR d/90079 is another instance of the same problem. (gdb) p/x *&s $11 = {a = 0x1, b = 0x2, c = 0x3, d = 0x4} (gdb) p s $12 = {a = 1 '\001', b = 2 '\002', c = 3 '\003', d = 4 '\004'} (gdb) p/x *(int *)&s $13 = 0x1020304 However, the test also FAILs on 64-bit SPARC where small structs *are* passed by value: (gdb) p s $1 = {a = 1 '\001', b = 2 '\002', c = 3 '\003', d = 4 '\004'} (gdb) p b $2 = "\000\000\000\000\000\000\000\000\000" (gdb) n 625 printf("%x\n", s); (gdb) n 0 626 sprintf(b.ptr, "%x", s); (gdb) n 630 assert(b[0 .. 7] == "1020304"); (gdb) p b $3 = "0\000\377\377\377\377\377\377\377\377" (gdb) p/x *(int *)&s $9 = 0x1020304 I don't fully see why yet, however all this strongly argues that this part of testcase is bogus: you cannot pass a struct to sprintf whose format string expects an int.