D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 13864 - [REG2.066] tuple expand causes range violation
Summary: [REG2.066] tuple expand causes range violation
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P1 regression
Assignee: No Owner
URL:
Keywords: pull, wrong-code
Depends on:
Blocks:
 
Reported: 2014-12-15 12:55 UTC by Vlad Levenfeld
Modified: 2015-02-18 03:41 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Vlad Levenfeld 2014-12-15 12:55:52 UTC
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 hsteoh 2014-12-16 15:47:58 UTC
Seems to work in git HEAD, tested on Linux/64. Maybe this has already been fixed?
Comment 2 Vlad Levenfeld 2014-12-16 16:11:10 UTC
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 Vlad Levenfeld 2014-12-16 16:13:16 UTC
this works as well:

		writeln (x[0]);
		auto y = x[0.tuple.expand];
		writeln (x[0.tuple.expand]); // ok again??
Comment 4 Vlad Levenfeld 2014-12-16 16:15:43 UTC
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 Vlad Levenfeld 2014-12-16 16:20:24 UTC
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.
Comment 7 github-bugzilla 2014-12-17 21:40:44 UTC
Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/872a1b649c3a13f3a6b1bcfdec8e6961671411eb
fix Issue 13864 - tuple expand causes range violation

https://github.com/D-Programming-Language/dmd/commit/626d64259c0d6d8ebbe6bb54da816558d6137306
Merge pull request #4216 from 9rnsr/fix13864

[REG2.066] Issue 13864 - tuple expand causes range violation