[Issue 10475] New: destructor is called on 'for' loop variable even when initialization failed
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed Jun 26 02:05:19 PDT 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10475
Summary: destructor is called on 'for' loop variable even when
initialization failed
Product: D
Version: unspecified
Platform: All
OS/Version: All
Status: NEW
Severity: normal
Priority: P2
Component: DMD
AssignedTo: nobody at puremagic.com
ReportedBy: nilsbossung at googlemail.com
Blocks: 10463
--- Comment #0 from Nils <nilsbossung at googlemail.com> 2013-06-26 02:05:11 PDT ---
This is reduced from issue 10463.
struct DirIterator
{
int _store = 42;
~this() {assert(_store == 42);} // line 4
}
DirIterator dirEntries()
{
throw new Exception(""); // line 9
}
void main()
{
/* This triggers only line 9: */
version(A) DirIterator a = dirEntries();
/* This triggers both lines 9 and 4: */
else version(B)
{
DirIterator b = void;
b = dirEntries();
}
/* With 'for' it looks like A, but behaves like B: */
else for(DirIterator c = dirEntries(); true;) {}
}
--
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