Bug 9264 – [64bit] Wrong code with conversion from int parameter to float
Status
RESOLVED
Resolution
FIXED
Severity
critical
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
All
Creation time
2013-01-03T03:56:00Z
Last change time
2015-06-09T05:11:44Z
Keywords
wrong-code
Assigned to
nobody
Creator
clugdbug
Comments
Comment #0 by clugdbug — 2013-01-03T03:56:07Z
float foo(float f) { return f*1.0f; }
float bar () { return 0.2; }
float bug9264 ( int x )
{
return bar() * foo( x );
}
----
_D3zug7bug9264FiZf:
push RBP
mov RBP,RSP
sub RSP,030h
mov -010h[RBP],EDI
call _D3zug3barFZf@PC32
movsd -020h[RBP],XMM0
sub RSP,8 <---------- PROBLEM HERE
mov EAX,-010h[RBP]
cvtsi2ss XMM0,EAX
call _D3zug3fooFfZf@PC32
movss -030h[RBP],XMM0
movss XMM1,-030h[RBP]
add RSP,8
movsd XMM0,-020h[RBP]
mulss XMM0,XMM1
leave
ret
.text._D3zug7bug9264FiZf ends
---
The problem is that the sub RSP, 8 leaves the stack misaligned. It needs to be aligned to 16 bytes.
Comment #1 by clugdbug — 2013-01-03T04:00:58Z
But it looks as though this is already fixed in git head, before the release of 1.076 and 2.061.
Comment #2 by clugdbug — 2013-01-03T04:18:45Z
Fixed in D1 commit 0726201e5bea65426ae2075280e4eb76b29ea6e8
Dec 24.
Comment #3 by bugzilla — 2013-01-03T10:15:46Z
"Already fixed" issues should be resolved as "WORKSFORME", otherwise the changelog fills up with duplicates.
Comment #4 by clugdbug — 2013-01-04T07:21:34Z
(In reply to comment #3)
> "Already fixed" issues should be resolved as "WORKSFORME", otherwise the
> changelog fills up with duplicates.
I marked it as FIXED deliberately. This was a really hideous bug, it caused intermittent hardware exceptions deep in C library code, and it took more than a week to track down. This is not a duplicate of anything in Bugzilla.
It's awesome that you noticed the bug in the source code and fixed it in the compiler release, just a few hours before we entered it into bugzilla. But it's not clear from the git log just what a critical bugfix it was.
It most definitely needs to appear in the changelog.