Bug 10475 – destructor is called on 'for' loop variable even when initialization failed
Status
RESOLVED
Resolution
DUPLICATE
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-06-26T02:05:00Z
Last change time
2015-06-09T05:14:49Z
Keywords
pull, wrong-code
Assigned to
nobody
Creator
nilsbossung
Comments
Comment #0 by nilsbossung — 2013-06-26T02:05:11Z
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;) {}
}
Comment #1 by maxim — 2013-06-26T08:43:37Z
I didn't dig this, but it looks like a dup of issue 8563
Comment #2 by nilsbossung — 2013-06-26T19:07:23Z
(In reply to comment #1)
> I didn't dig this, but it looks like a dup of issue 8563
Yup, closing.
*** This issue has been marked as a duplicate of issue 8563 ***
(In reply to comment #2)
> *** This issue has been marked as a duplicate of issue 8563 ***
(In reply to comment #3)
> https://github.com/D-Programming-Language/dmd/pull/2286
Does that patch fix issue 8563 or is this issue not a proper duplicate of 8563?
Comment #5 by k.hara.pg — 2013-07-01T07:01:17Z
(In reply to comment #4)
> (In reply to comment #2)
> > *** This issue has been marked as a duplicate of issue 8563 ***
>
> (In reply to comment #3)
> > https://github.com/D-Programming-Language/dmd/pull/2286
>
> Does that patch fix issue 8563 or is this issue not a proper duplicate of 8563?
Because I couldn't reproduce segfault in Windoes 7 64bit (== 32bit codegen) environment. Right now I don't have x86_64 environment, so currently I don't have enough confidence that the PR fixes bug 8563...
Comment #6 by github-bugzilla — 2013-07-02T00:43:41Z