[Issue 6659] New: Destructor in range foreach called after initialization
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Sep 13 00:12:10 PDT 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6659
Summary: Destructor in range foreach called after
initialization
Product: D
Version: D2
Platform: Other
OS/Version: FreeBSD
Status: NEW
Severity: normal
Priority: P2
Component: DMD
AssignedTo: nobody at puremagic.com
ReportedBy: dawg at dawgfoto.de
--- Comment #0 from dawg at dawgfoto.de 2011-09-13 00:11:52 PDT ---
void main()
{
static struct Iter
{
~this()
{
++_dtor;
}
bool opCmp(ref const Iter rhs) { return _pos == rhs._pos; }
void opUnary(string op:"++")() { ++_pos; }
size_t _pos;
static size_t _dtor;
}
foreach(ref iter; Iter(0) .. Iter(10))
{
assert(Iter._dtor == 0);
}
assert(Iter._dtor == 2);
}
---
The iteration is done using destructed instances.
--
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