***************************************
NOTE: THIS ***JUST*** BROKE IN GIT HEAD.
***************************************
I had this pull:
https://github.com/D-Programming-Language/phobos/pull/992
Which was working fine, and then just spontaneously broke on the 8th:
http://d.puremagic.com/test-results/pull-history.ghtml?projectid=1&repoid=3&pullid=992
Looks like a compiler or codegen bug:
Basically, if, inside a member function, you want a slice, you'd write "this[a .. b]".
Now, if you want to slice to the end, you'd write "this[a .. $]" problem is that in this specific case, the wrong "this" is passed to opDollar. What is strange is that it *only* happens when the words "this", and "$" are mixed together. It does not happen if you call "s[1 .. $]" or "this[1 .. opDollar()]":
//----
import std.stdio;
struct S
{
size_t opDollar()
{
writeln("Inside opDollar ", cast(void*)&this);
return 10;
}
void opSlice(size_t , size_t)
{
writeln("Inside opSlice: ", cast(void*)&this);
}
void getSlice()
{
writeln("Inside get: ", cast(void*)&this);
writeln("Normal");
this[1 .. opDollar()];
writeln("wait for it:");
this[1 .. $];
}
}
void main()
{
S s;
writeln("Main: ", cast(void*)&s);
s.getSlice();
writeln("not here:");
s[1 .. $];
}
//----
Main: 18FD70
Inside get: 18FD70
Normal
Inside opDollar 18FD70
Inside opSlice: 18FD70
wait for it:
Inside opDollar 18FD74 <-- HERE: wrong this.
Inside opSlice: 18FD70
not here:
Inside opDollar 18FD70
Inside opSlice: 18FD70
//----
With more fancy scenarios, I've had more extreme values for this, including "0", "4" and "D"
Comment #1 by monarchdodra — 2013-02-10T11:59:32Z
(In reply to comment #0)
> ***************************************
> NOTE: THIS ***JUST*** BROKE IN GIT HEAD.
> ***************************************
Forgot to mention, the test case works correctly in 2.061.
Comment #2 by maxim — 2013-02-10T12:23:46Z
(In reply to comment #0)
> ***************************************
> NOTE: THIS ***JUST*** BROKE IN GIT HEAD.
> ***************************************
Why so emotional? Instead you can be more informative by telling that it happens with -m32 (at least I cannot reproduce on linux with -m64). Why did you decide that recent dmd pulls break this code?
Comment #3 by andrej.mitrovich — 2013-02-10T12:37:44Z
I can't reproduce this on win32. Can you specify which flags/platform you're using?
Comment #4 by maxim — 2013-02-10T12:44:35Z
I can reproduce on linux64 githead for both -m32 and m64
import core.stdc.stdio : printf;
struct S
{
int i;
size_t opDollar()
{
printf("Inside opDollar: %p\n", cast(void*)&this );
//i = 0;
return 10;
}
void opSlice(size_t , size_t)
{
printf("Inside opSlice: %p\n", cast(void*)&this);
}
void getSlice()
{
printf("Inside get: %p\n", cast(void*)&this);
this[1 .. $];
}
}
void main()
{
S s;
s.getSlice();
}
With -m32 and -m64 there is incorrect address in opDollar. With -inline it's fine, with -g there is AssertError ("null this") and with -O I have "Error: variable __dop5 used before set".
Comment #5 by issues.dlang — 2013-02-10T12:53:47Z
Yeah. On 64-bit Linux, I'm getting
Main: 7FFF39C7A4D8
Inside get: 7FFF39C7A4D8
Normal
Inside opDollar 7FFF39C7A4D8
Inside opSlice: 7FFF39C7A4D8
wait for it:
Inside opDollar 10
Inside opSlice: 7FFF39C7A4D8
not here:
Inside opDollar 7FFF39C7A4D8
Inside opSlice: 7FFF39C7A4D8
Comment #6 by andrej.mitrovich — 2013-02-10T12:55:56Z
Introduced by commit:
commit 6e2f1ec1abfacf61f9f156ccf5b814a3f6e26591
Author: k-hara <[email protected]>
Date: Wed Feb 6 12:27:35 2013 +0900
fix Issue 9453 - ice(symbol.c) with slice on temporary
Comment #7 by monarchdodra — 2013-02-10T23:03:17Z
(In reply to comment #2)
> (In reply to comment #0)
> > ***************************************
> > NOTE: THIS ***JUST*** BROKE IN GIT HEAD.
> > ***************************************
>
> Why so emotional? Instead you can be more informative by telling that it
> happens with -m32 (at least I cannot reproduce on linux with -m64). Why did you
> decide that recent dmd pulls break this code?
NOt really emotional, just clumsy I guess. I wanted to make sure to stress that something just broke: If we can easilly track down the change now, it greatly increases the chances of this being fixed, and may save someone hours of debugging.
Apologies for forgetting to mention my version: Standard w32, with no switches. I also usually check linux 32/64 with dpaste, but the dpaste compiler has been down for a while, so I couldn't check.
I decided a recent dmd pull breaks the code because my code spontaneously stopped working, and because I could reproduce the bug on something that does not depend on phobos.
I'm not *blaming* anyone or anything. It's just that in my experience, fixing something is 10 times easier if you can track down *what* broke it in the first place. So I wanted to make sure we don't miss that window.
Comment #8 by k.hara.pg — 2013-02-10T23:19:20Z
https://github.com/D-Programming-Language/dmd/pull/1655
(In reply to comment #7)
> NOt really emotional, just clumsy I guess. I wanted to make sure to stress that
> something just broke: If we can easilly track down the change now, it greatly
> increases the chances of this being fixed, and may save someone hours of
> debugging.
I especially observe regression issues, at least in beta phase. To me, "Importance: regression" is enough.
Comment #9 by github-bugzilla — 2013-02-11T23:14:52Z