Bug 13864 – [REG2.066] tuple expand causes range violation
Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2014-12-15T12:55:00Z
Last change time
2015-02-18T03:41:22Z
Keywords
pull, wrong-code
Assigned to
nobody
Creator
vlevenfeld
Comments
Comment #0 by vlevenfeld — 2014-12-15T12:55:52Z
import std.typecons;
void main (string[] args)
{/*...}*/
int[] x = [2,3,4];
writeln (x[0]);
writeln (x[0.tuple.expand]); // BUG range violation
}
Comment #1 by hsteoh — 2014-12-16T15:47:58Z
Seems to work in git HEAD, tested on Linux/64. Maybe this has already been fixed?
Comment #2 by vlevenfeld — 2014-12-16T16:11:10Z
I'm using git HEAD, I still get the range violation. Not only that but this:
auto y = x[0];
auto z = x[0.tuple.expand]; // ok
runs fine. (got rid of writeln)
but also this:
auto y = x[0];
writeln (x[0.tuple.expand]); // ok
and this:
writeln (x[0]);
auto z = x[0.tuple.expand]; // ok
not sure whats going on, I just recompiled dmd from the latest
Comment #3 by vlevenfeld — 2014-12-16T16:13:16Z
this works as well:
writeln (x[0]);
auto y = x[0.tuple.expand];
writeln (x[0.tuple.expand]); // ok again??
Comment #4 by vlevenfeld — 2014-12-16T16:15:43Z
its not writeln, this works as well:
auto f (T...)(T)
{
}
void main (string[] args)
{
int[] x = [2,3,4];
f (x[0]);
auto a = x[0.tuple.expand]; // range violation if commented out
f (x[0.tuple.expand]);
}
Comment #5 by vlevenfeld — 2014-12-16T16:20:24Z
It only seems to happen with T[] types, struct with opIndex to catch and print args confirms that the tuple expand call just resolves to a 0 int. Np luck catching it with gdb so far, the violation goes off as soon as that line is reached.