[Issue 9496] New: [REG 2.061 -> 2.062 alpha] "this[1 .. $]" passes wrong "this" to "opDollar"
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sun Feb 10 11:59:01 PST 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9496
Summary: [REG 2.061 -> 2.062 alpha] "this[1 .. $]" passes wrong
"this" to "opDollar"
Product: D
Version: D2
Platform: All
OS/Version: All
Status: NEW
Severity: major
Priority: P2
Component: DMD
AssignedTo: nobody at puremagic.com
ReportedBy: monarchdodra at gmail.com
--- Comment #0 from monarchdodra at gmail.com 2013-02-10 11:58:59 PST ---
***************************************
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"
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list