Bug 10678 – Win64: wrong code passing small fixed sized array as function argument

Status
RESOLVED
Resolution
FIXED
Severity
critical
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Windows
Creation time
2013-07-20T02:02:00Z
Last change time
2015-06-09T05:10:41Z
Keywords
wrong-code
Assigned to
nobody
Creator
r.sagitario

Comments

Comment #0 by r.sagitario — 2013-07-20T02:02:45Z
extracted from std.format unittests: //////////////////////////////////// enum size = 5; char[size] ret() { char[size] hello = "hello world"[0..size]; return hello; } void test(char[size] txt) { assert(txt == "hello world"[0..size]); // fails } void main() { auto r = ret(); assert(r == "hello world"[0..size]); // passes test(r); } ///////////////////////////////////// compile with "dmd -m64 test.d" to trigger the assertion. This happens for array sizes 5, 6 and 7. This might be related to issue 9586.
Comment #1 by bugzilla — 2013-07-27T13:39:08Z
Smaller test case: int test(char[5] txt) { return txt[0] + txt[1] + txt[4]; } void main() { char[5] hello = void; hello[0] = 8; hello[1] = 9; hello[4] = 10; int i = test(hello); assert(i == 27); }
Comment #2 by bugzilla — 2013-07-27T13:41:57Z
Comment #3 by github-bugzilla — 2013-07-27T22:28:26Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/92251d67a0a59d4c22d6cb8c7e7557f8d0109bf3 fix Issue 10678 - Win64: wrong code passing small fixed sized array as function argument https://github.com/D-Programming-Language/dmd/commit/e0eefafa57a5f765f44268507213991ebaacc9db Merge pull request #2391 from WalterBright/fix10678 fix Issue 10678 - Win64: wrong code passing small fixed sized array as f...
Comment #4 by github-bugzilla — 2013-07-27T22:58:46Z
Commit pushed to dmd-1.x at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/31b45dbc23f75465b87f25168f4a3ae2bfdc31b2 Merge pull request #2391 from WalterBright/fix10678 fix Issue 10678 - Win64: wrong code passing small fixed sized array as f...