www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 10475] New: destructor is called on 'for' loop variable even when initialization failed

reply d-bugmail puremagic.com writes:
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



---
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: -------
Jun 26 2013
next sibling parent d-bugmail puremagic.com writes:
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



---
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: -------
Jun 26 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10475


Nils <nilsbossung googlemail.com> changed:

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



---

 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: -------
Jun 26 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
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



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: -------
Jul 01 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10475




---

 *** This issue has been marked as a duplicate of issue 8563 ***
 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: -------
Jul 01 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10475






 *** This issue has been marked as a duplicate of issue 8563 ***
 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: -------
Jul 01 2013
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10475




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


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: -------
Jul 02 2013