[Issue 8796] Optimizer bug on 64bit: *p++=1 where p is a parameter
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Nov 5 11:43:24 PST 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8796
Don <clugdbug at yahoo.com.au> changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|Optimizer bug on 64bit |Optimizer bug on 64bit:
| |*p++=1 where p is a
| |parameter
--- Comment #1 from Don <clugdbug at yahoo.com.au> 2012-11-05 11:43:22 PST ---
Reduced test case (applies to postfix ++ and --):
int* wrong8796(int* p)
{
*p++ = 1;
return p;
}
// The wrong code is generated in the function above, main() is just to
demonstrate
void main()
{
int [3] arr;
int * q = arr.ptr;
q = wrong8796(q);
assert(q != arr.ptr);
}
Without -O, wrong8796() compiles to:
push RBP
mov RBP,RSP
sub RSP,8
mov -8[RBP],RDI
mov RAX,-8[RBP]
add qword ptr -8[RBP],4
mov dword ptr [RAX],1
mov RAX,-8[RBP]
leave
ret
With -O:
push RBP
mov RBP,RSP
mov RAX,RDI
mov qword ptr [RAX],1
add RAX,4
mov RAX,RDI <---- wrong
pop RBP
ret
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list