[Issue 6418] [CTFE] Cannot call a struct member function with name 'length'.
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sun Jul 31 15:17:33 PDT 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6418
kennytm at gmail.com changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |ice-on-valid-code,
| |rejects-valid
CC| |kennytm at gmail.com
Summary|[CTFE] segfault on |[CTFE] Cannot call a struct
|SortedRange.equalRange |member function with name
| |'length'.
--- Comment #1 from kennytm at 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: -------
More information about the Digitalmars-d-bugs
mailing list