https://d.puremagic.com/issues/show_bug.cgi?id=11740
Summary: [64-bit] Struct with constructor incorrectly passed on stack Product: D Version: D2 Platform: x86_64 OS/Version: All Status: NEW Keywords: wrong-code Severity: critical Priority: P2 Component: DMD AssignedTo: nob...@puremagic.com ReportedBy: yebbl...@gmail.com --- Comment #0 from yebblies <yebbl...@gmail.com> 2013-12-15 04:22:12 EST --- In func, 's' is passed on the stack instead of in a register pair, only when the constructor is present. This blocks DDMD on linux64. extern(C++) class C { extern(C++) static void func(S s, C c) { assert(c); assert(s.filename); assert(s.linnum); } } struct S { const(char)* filename; uint linnum; this(const(char)* filename, uint linnum) {} } int main() { C.func(S(null, 0), null); return 0; } 0000000000000000 <_ZN1C4funcE1SPS_>: 0: 55 push %rbp 1: 48 8b ec mov %rsp,%rbp 4: 48 83 ec 10 sub $0x10,%rsp 8: 48 89 7d f8 mov %rdi,-0x8(%rbp) (should be in rdx, not rdi) c: 48 83 7d f8 00 cmpq $0x0,-0x8(%rbp) 11: 75 0a jne 1d <_ZN1C4funcE1SPS_+0x1d> 13: bf 07 00 00 00 mov $0x7,%edi 18: e8 00 00 00 00 callq 1d <_ZN1C4funcE1SPS_+0x1d> 19: R_X86_64_PC32 _D4test8__assertFiZv-0x4 1d: 48 83 7d 10 00 cmpq $0x0,0x10(%rbp) 22: 75 0a jne 2e <_ZN1C4funcE1SPS_+0x2e> 24: bf 08 00 00 00 mov $0x8,%edi 29: e8 00 00 00 00 callq 2e <_ZN1C4funcE1SPS_+0x2e> 2a: R_X86_64_PC32 _D4test8__assertFiZv-0x4 2e: 83 7d 18 00 cmpl $0x0,0x18(%rbp) 32: 75 0a jne 3e <_ZN1C4funcE1SPS_+0x3e> 34: bf 09 00 00 00 mov $0x9,%edi 39: e8 00 00 00 00 callq 3e <_ZN1C4funcE1SPS_+0x3e> 3a: R_X86_64_PC32 _D4test8__assertFiZv-0x4 3e: c9 leaveq 3f: c3 retq It works correctly if StructDeclaration::isPOD is changed to not reject all structs with constructors, but there is a comment warning against that. -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------