Thread overview | ||||||
---|---|---|---|---|---|---|
|
November 08, 2010 [Issue 5188] New: alias this and compare expression generates wrong code | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=5188 Summary: alias this and compare expression generates wrong code Product: D Version: D2 Platform: x86 OS/Version: Windows Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: nobody@puremagic.com ReportedBy: k.hara.pg@gmail.com --- Comment #0 from Kenji Hara <k.hara.pg@gmail.com> 2010-11-08 06:17:11 PST --- // bug.d struct S { int v = 10; alias v this; } void main() { S s; assert(s <= 20); // fail!? } // use ddbg 0.11 beta bug.d:6 void main() 00402010: c8040000 enter 0x4, 0x0 bug.d:8 S s; 00402014: a180504100 mov eax, [0x415080] 00402019: 8945fc mov [ebp-0x4], eax bug.d:9 assert(s <= 20); 0040201c: 837dfc14 cmp dword [ebp-0x4], 0x14 00402020: b901000000 mov ecx, 0x1 00402025: 7e02 jle 0x402029 _Dmain bug.d:9 // jump to 0x402029 00402027: 31c9 xor ecx, ecx // not run 00402029: 31d2 xor edx, edx // edx = 0 0040202b: 3bca cmp ecx, edx // ecx==1, edx==0 0040202d: 7e0a jle 0x402039 _Dmain bug.d:9 // fail 0040202f: b809000000 mov eax, 0x9 // eax = 9 00402034: e807000000 call 0x402040 bug.__assert // assert! 00402039: 31c0 xor eax, eax bug.d:10 } 0040203b: c9 leave 0040203c: c3 ret -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
July 22, 2011 [Issue 5188] alias this and compare expression generates wrong code | ||||
---|---|---|---|---|
| ||||
Posted in reply to Kenji Hara | http://d.puremagic.com/issues/show_bug.cgi?id=5188 kennytm@gmail.com changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |wrong-code CC| |kennytm@gmail.com Platform|x86 |All OS/Version|Windows |All --- Comment #1 from kennytm@gmail.com 2011-07-22 03:13:19 PDT --- If we set a break point at FuncDeclaration::toObjFile at glue.c and print 'fbody->toChars()', we'll see that the function void main() { S s; assert(s <= 20); // fail!? } has been semantic into int main() { S s = _D1x1S6__initZ; assert(cast(int)(s.v <= 20) <= 0); // ^^ return 0; } The extra '<= 0' causes the assertion to fail. Apparently DMD thinks there is an opCmp/opEquals. This also applies for '!=': assert(s != 14); which is semantic into assert(!(s.v != 14)); -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
July 26, 2011 [Issue 5188] alias this and compare expression generates wrong code | ||||
---|---|---|---|---|
| ||||
Posted in reply to Kenji Hara | http://d.puremagic.com/issues/show_bug.cgi?id=5188 Kenji Hara <k.hara.pg@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |patch --- Comment #2 from Kenji Hara <k.hara.pg@gmail.com> 2011-07-26 10:39:58 PDT --- (In reply to comment #1) Thanks for your explaining. Today I can create patch for this bug. https://github.com/D-Programming-Language/dmd/pull/275 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
August 11, 2011 [Issue 5188] alias this and compare expression generates wrong code | ||||
---|---|---|---|---|
| ||||
Posted in reply to Kenji Hara | http://d.puremagic.com/issues/show_bug.cgi?id=5188 Walter Bright <bugzilla@digitalmars.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |bugzilla@digitalmars.com Resolution| |FIXED --- Comment #3 from Walter Bright <bugzilla@digitalmars.com> 2011-08-11 01:28:57 PDT --- https://github.com/D-Programming-Language/dmd/commit/d419e8c4b675f70cae5e1784e500c2fc6fdf0f9d -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
Copyright © 1999-2021 by the D Language Foundation