Thread overview
[Issue 10475] New: destructor is called on 'for' loop variable even when initialization failed
Jun 26, 2013
Nils
Jun 26, 2013
Maxim Fomin
Jun 27, 2013
Nils
Jul 01, 2013
Kenji Hara
Jul 01, 2013
Nils
Jul 01, 2013
Kenji Hara
June 26, 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@puremagic.com
        ReportedBy: nilsbossung@googlemail.com
            Blocks: 10463


--- Comment #0 from Nils <nilsbossung@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: -------
June 26, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10475


Maxim Fomin <maxim@maxim-fomin.ru> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |maxim@maxim-fomin.ru


--- Comment #1 from Maxim Fomin <maxim@maxim-fomin.ru> 2013-06-26 08:43:37 PDT ---
I didn't dig this, but it looks like a dup of issue 8563

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
June 27, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10475


Nils <nilsbossung@googlemail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |DUPLICATE


--- Comment #2 from Nils <nilsbossung@googlemail.com> 2013-06-26 19:07:23 PDT ---
(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 ***

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
July 01, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10475


Kenji Hara <k.hara.pg@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull, wrong-code


--- Comment #3 from Kenji Hara <k.hara.pg@gmail.com> 2013-07-01 01:43:37 PDT ---
https://github.com/D-Programming-Language/dmd/pull/2286

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
July 01, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10475



--- Comment #4 from Nils <nilsbossung@googlemail.com> 2013-07-01 06:30:35 PDT ---
(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?

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
July 01, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10475



--- Comment #5 from Kenji Hara <k.hara.pg@gmail.com> 2013-07-01 07:01:17 PDT ---
(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...

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
July 02, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10475



--- Comment #6 from github-bugzilla@puremagic.com 2013-07-02 00:43:41 PDT ---
Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/6c7d77f690f509255950321e3e0fec9f29d02df6
fix Issue 10475 - destructor is called on 'for' loop variable even when
initialization failed

https://github.com/D-Programming-Language/dmd/commit/aaf64112624abab1f6cc8f610223f6e12b525e09 Merge pull request #2286 from 9rnsr/fix10475

Issue 10475 - destructor is called on 'for' loop variable even when initialization failed

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------