digitalmars.D.bugs - [Issue 2601] New: Extraneous cast introduced in member access
- d-bugmail puremagic.com (41/41) Jan 21 2009 http://d.puremagic.com/issues/show_bug.cgi?id=2601
- d-bugmail puremagic.com (19/19) Jan 15 2010 http://d.puremagic.com/issues/show_bug.cgi?id=2601
- d-bugmail puremagic.com (14/14) Jun 12 2011 http://d.puremagic.com/issues/show_bug.cgi?id=2601
http://d.puremagic.com/issues/show_bug.cgi?id=2601 Summary: Extraneous cast introduced in member access Product: D Version: unspecified Platform: PC OS/Version: Linux Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: bugzilla digitalmars.com ReportedBy: andrei metalanguage.com I could probably simplify this a bit more, but it's short enough: import std.functional; void next(T)(ref T[] a) { assert(a.length); a = a[1 .. $]; } struct MapRange(alias funAlias, Range) { Range _input; void next() { _input.next; } } template map(fun...) { alias mapImpl!(fun).result map; } template mapImpl(alias fun) { MapRange!(fun, Range) result(Range)(Range input) { return typeof(return)(input); } } unittest { auto x = map!("2 * a")([1, 2, 3, 4, 5]); //auto y = mapImpl!(fun).result!("2 * a")([1, 2, 3, 4, 5]); } The code fails to compile with: Error: cast(int[])this._input is not an lvalue As a bonus, uncommenting the last (albeit incorrect) line in unittest crashes dmd. --
Jan 21 2009
http://d.puremagic.com/issues/show_bug.cgi?id=2601 Don <clugdbug yahoo.com.au> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords|ice-on-invalid-code |rejects-valid Version|2.000 |1.050 The segfault was fixed long ago. Reduced test case also fails on D1. I'm not certain it's a bug, though. -------- void next(ref int[] a) { a[0] = 0; } void bug2601() { int[3] b; next(b); } bug.d(5): Error: cast(int[])b is not an lvalue -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jan 15 2010
http://d.puremagic.com/issues/show_bug.cgi?id=2601 yebblies <yebblies gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |yebblies gmail.com Resolution| |FIXED I think array literals have become dynamic since then, so the case in comment 1 works. The case in comment 2 does not appear to be a bug, casting a static array to a dynamic array cannot result in an lvalue. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jun 12 2011