Thread overview | ||||||||
---|---|---|---|---|---|---|---|---|
|
July 31, 2011 [Issue 6418] New: [CTFE] segfault on SortedRange.equalRange | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=6418 Summary: [CTFE] segfault on SortedRange.equalRange Product: D Version: D2 Platform: Other OS/Version: All Status: NEW Severity: major Priority: P2 Component: DMD AssignedTo: nobody@puremagic.com ReportedBy: dmitry.olsh@gmail.com --- Comment #0 from Dmitry Olshansky <dmitry.olsh@gmail.com> 2011-07-31 11:16:16 PDT --- Test case: import std.range; enum table = [2, 3, 5, 7, 11]; uint lookup(uint k) { auto tab = assumeSorted(table); tab.equalRange(k); //changing it to lowerBound works assert(!tab.empty); return 42; } enum t = lookup(7); invking dmd: dmd2/linux/bin/../../src/phobos/std/range.d(5572): Error: cannot evaluate this.length() at compile time dmd2/linux/bin/../../src/phobos/std/range.d(5620): Error: cannot evaluate this.getTransitionIndex(v) at compile time dmd2/linux/bin/../../src/phobos/std/range.d(5620): Error: cannot evaluate this.opSlice(0LU,this.getTransitionIndex(v)) at compile time dmd2/linux/bin/../../src/phobos/std/range.d(5693): Error: cannot evaluate this.opSlice(first,it).lowerBound(value) at compile time Segmentation fault (core dumped) -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
July 31, 2011 [Issue 6418] [CTFE] Cannot call a struct member function with name 'length'. | ||||
---|---|---|---|---|
| ||||
Posted in reply to Dmitry Olshansky | http://d.puremagic.com/issues/show_bug.cgi?id=6418 kennytm@gmail.com changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |ice-on-valid-code, | |rejects-valid CC| |kennytm@gmail.com Summary|[CTFE] segfault on |[CTFE] Cannot call a struct |SortedRange.equalRange |member function with name | |'length'. --- Comment #1 from kennytm@gmail.com 2011-07-31 15:17:29 PDT --- Reduced test case (which doesn't trigger the ICE, but should have the same cause): --------------------- struct Bug6418 { size_t length2() { return 1; } size_t length() { return 1; } } static assert(Bug6418.init.length2 == 1); // <-- ok static assert(Bug6418.init.length == 1); // <-- error --------------------- x.d(6): Error: cannot evaluate Bug6418().length() at compile time x.d(6): Error: static assert (Bug6418().length() == 1u) is not evaluatable at compile time --------------------- Temporary workaround to Phobos is to change all 'length' to '_input.length': diff --git a/std/range.d b/std/range.d index 622f7b8..a8e4e4e 100644 --- a/std/range.d +++ b/std/range.d @@ -5618,7 +5618,7 @@ if (isRandomAccessRange!Range) private size_t getTransitionIndex(SearchPolicy sp, alias test, V)(V v) if (sp == SearchPolicy.trotBackwards || sp == SearchPolicy.gallopBackwards) { - immutable count = length; + immutable count = _input.length; if (empty || !test(back, v)) return count; if (count == 1) return 0; size_t below = count - 2, above = count - 1, step = 2; @@ -5690,7 +5690,7 @@ if (isRandomAccessRange!Range) if (is(V : ElementType!Range)) { ElementType!Range v = value; - return this[getTransitionIndex!(sp, gt)(v) .. length]; + return this[getTransitionIndex!(sp, gt)(v) .. _input.length]; } // equalRange @@ -5739,12 +5739,12 @@ if (isRandomAccessRange!Range) // Gallop towards the left end as it's likely nearby immutable left = first + this[first .. it] - .lowerBound!(SearchPolicy.gallopBackwards)(value).length; + .lowerBound!(SearchPolicy.gallopBackwards)(value)._input.length; first += count; // Gallop towards the right end as it's likely nearby immutable right = first - this[it + 1 .. first] - .upperBound!(SearchPolicy.gallop)(value).length; + .upperBound!(SearchPolicy.gallop)(value)._input.length; return this[left .. right]; } } -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
August 01, 2011 [Issue 6418] [CTFE] Cannot call a struct member function with name 'length'. | ||||
---|---|---|---|---|
| ||||
Posted in reply to Dmitry Olshansky | http://d.puremagic.com/issues/show_bug.cgi?id=6418 Don <clugdbug@yahoo.com.au> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |clugdbug@yahoo.com.au --- Comment #2 from Don <clugdbug@yahoo.com.au> 2011-07-31 21:41:04 PDT --- There are two bugs here. The segfault has a completely different cause from the rejects-valid bug. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
August 04, 2011 [Issue 6418] [CTFE] Cannot call a struct member function with name 'length'. | ||||
---|---|---|---|---|
| ||||
Posted in reply to Dmitry Olshansky | http://d.puremagic.com/issues/show_bug.cgi?id=6418 Walter Bright <bugzilla@digitalmars.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |bugzilla@digitalmars.com Resolution| |FIXED --- Comment #3 from Walter Bright <bugzilla@digitalmars.com> 2011-08-03 17:15:34 PDT --- https://github.com/D-Programming-Language/dmd/commit/9318dc44c3e9aa75907966b9fd122c0cc6700891 https://github.com/D-Programming-Language/dmd/commit/571661646ca420aa4c3fb348e86e35ed8faae624 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
Copyright © 1999-2021 by the D Language Foundation