[Issue 5798] Weakly pure function calls skipped inside a comma expression
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Apr 25 02:22:28 PDT 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5798
--- Comment #3 from kennytm at gmail.com 2011-04-25 02:14:51 PDT ---
Comma expression is also used in for-loops, which may trigger this bug. In
particular, the equal() function since commit ec2c8460* does not work with a
range with pure popFront() since it says
for (; !r1.empty; r1.popFront(), r2.popFront())
// ^
For instance, the following code, which works in 2.052, no longer work in the
git master version:
-----------------------------------------------------------------
import std.array, std.algorithm;
struct X {
int _front;
pure nothrow:
@property int front() const { return _front; }
void popFront() { ++ _front; }
@property bool empty() const { return _front == 10; }
}
void main() {
X x;
//assert(equal(array(x), [0,1,2,3,4,5,6,7,8,9])); // ok
x._front = 0;
assert(equal(x, [0,1,2,3,4,5,6,7,8,9])); // asserts
}
-----------------------------------------------------------------
* https://github.com/D-Programming-Language/phobos/commit/ec2c8460#L0R4324
--
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