D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 10678 - Win64: wrong code passing small fixed sized array as function argument
Summary: Win64: wrong code passing small fixed sized array as function argument
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: x86_64 Windows
: P2 critical
Assignee: No Owner
URL:
Keywords: wrong-code
Depends on:
Blocks:
 
Reported: 2013-07-20 02:02 UTC by Rainer Schuetze
Modified: 2015-06-09 05:10 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Rainer Schuetze 2013-07-20 02:02:45 UTC
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 Walter Bright 2013-07-27 13:39:08 UTC
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 3 github-bugzilla 2013-07-27 22:28:26 UTC
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 github-bugzilla 2013-07-27 22:58:46 UTC
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...