https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88462
--- Comment #7 from ro at CeBiTec dot Uni-Bielefeld.DE <ro at CeBiTec dot Uni-Bielefeld.DE> --- > --- Comment #6 from Iain Buclaw <ibuclaw at gdcproject dot org> --- >> 8, but that let the constructor already fail the first time through >> where _d_arraycopy checks that the right amount of data is copied: >> >> _d_arraycopy -> rt.util.array.enforceRawArraysConformable -> >> rt.util.array._enforceSameLength > > What you're doing rounding up the array size is correct. The bit you're > missing is fixing up the slice assignment as well. > > lock[0 .. __traits(classInstanceSize, Mutex)] = typeid(Mutex).initializer[]; That got me over this issue indeed, thanks. However, I now hit the next issue: a SIGBUS (which gdb incorrectly reports as SIGSEGV) due to an alignement issue: Thread 2 received signal SIGSEGV, Segmentation fault. [Switching to Thread 1 (LWP 1)] 0x0007c970 in object.ModuleInfo.flags() const (this=...) at /vol/gcc/src/hg/trunk/solaris/libphobos/libdruntime/object.d:1541 1541 @property uint flags() nothrow pure @nogc { return _flags; } (gdb) where #0 0x0007c970 in object.ModuleInfo.flags() const (this=...) at /vol/gcc/src/hg/trunk/solaris/libphobos/libdruntime/object.d:1541 #1 0x0007d118 in object.ModuleInfo.importedModules() const (this=...) at /vol/gcc/src/hg/trunk/solaris/libphobos/libdruntime/object.d:1580 #2 0x0008ed74 in rt.minfo.ModuleGroup.sortCtors(immutable(char)[]) (this=..., cycleHandling=...) at /vol/gcc/src/hg/trunk/solaris/libphobos/libdruntime/rt/minfo.d:259 #3 0x00091110 in rt.minfo.ModuleGroup.sortCtors() (this=...) at /vol/gcc/src/hg/trunk/solaris/libphobos/libdruntime/rt/minfo.d:533 #4 0x00092d24 in __foreachbody1 (this=0x0, sg=...) at /vol/gcc/src/hg/trunk/solaris/libphobos/libdruntime/rt/minfo.d:795 #5 0x00097a08 in rt.sections_elf_shared.DSO.opApply(scope int(ref rt.sections_elf_shared.DSO) delegate) (dg=...) at /vol/gcc/src/hg/trunk/solaris/libphobos/libdruntime/rt/sections_elf_shared.d:68 #6 0x00092ce8 in rt_moduleCtor () at /vol/gcc/src/hg/trunk/solaris/libphobos/libdruntime/rt/minfo.d:793 #7 0x00085dbc in rt_init () at /vol/gcc/src/hg/trunk/solaris/libphobos/libdruntime/rt/dmain2.d:190 #8 0x000867e8 in runAll (this=0xffbfe78c) at /vol/gcc/src/hg/trunk/solaris/libphobos/libdruntime/rt/dmain2.d:485 #9 0x00086740 in tryExec (this=0xffbfe78c, dg=...) at /vol/gcc/src/hg/trunk/solaris/libphobos/libdruntime/rt/dmain2.d:461 #10 0x0008664c in _d_run_main (argc=1, argv=0xffbfe8bc, mainFunc=0x6c164 <D main>) at /vol/gcc/src/hg/trunk/solaris/libphobos/libdruntime/rt/dmain2.d:494 #11 0x0006b7e4 in main (argc=1, argv=0xffbfe8bc) at /vol/gcc/src/hg/trunk/solaris/libphobos/libdruntime/__entrypoint.di:44 #12 0x0006b5d4 in _start () Backtrace stopped: previous frame identical to this frame (corrupt stack?) (gdb) p this $5 = (const object.ModuleInfo &) @0x12ab33: {_flags = 4100, _index = 0} (gdb) x/i $pc => 0x7c970 <_D6object10ModuleInfo5flagsMxFNaNbNdNiZk+152>: ld [ %g1 ], %g1 (gdb) p/x $g1 $6 = 0x12ab33 Trying to load 32 bits from a non-4 byte aligned pointer is a no-no on a strict-alignment target like sparc...