64 bit only. Originally found in D1, but also applies to D2.
------
int bug9568(ref string x)
{
string y = x;
scope (success)
{
assert(x == y);
}
return 0;
}
void main()
{
string e = "xxx";
int result = bug9568(e);
assert( ! result ); // fails
}
Comment #1 by clugdbug — 2013-02-22T01:33:13Z
Slightly clearer test case, which works unaltered on D1 as well. It is necessary for both x and y to be passed as parameters (this was happening with x==y in my first test case, which was making a call to the runtime).
------
void use9568(char [] m, char [] p) {}
int bug9568(ref char[] x)
{
char[] y = x;
scope (success)
use9568(x,y);
return 7;
}
void main()
{
char[] e = null;
assert( bug9568(e) == 7 );
}
Comment #2 by clugdbug — 2013-02-22T01:42:18Z
And it's a regression (at least on D1, haven't checked old versions of D2). This code worked in 1.074 and 1.075, fails in 1.076.
Comment #3 by clugdbug — 2013-02-22T02:55:30Z
Also applies to scope(exit), which is more important because it is more commonly used.
Comment #4 by clugdbug — 2013-02-22T03:40:06Z
Even further reduced. Reference parameter is not necessary. I also replaced the scope(exit) with a try{}finally{} block, which is what happens in the front-end.
==================
void use9568(char [] x, char [] y) {}
int bug9568()
{
try
return 7;
finally
use9568(null,null);
}
void main()
{
assert( bug9568() == 7 );
}
Comment #5 by github-bugzilla — 2013-02-24T23:48:07Z