www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 7049] New: Multiple scope(failure) blocks don't work in safe code

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7049

           Summary: Multiple scope(failure) blocks don't work in  safe
                    code
           Product: D
           Version: D2
          Platform: Other
        OS/Version: All
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: code klickverbot.at



---
---
 safe void foo() {
  scope (failure) {}
  scope (failure) {}
}
---

DMD 2.057 Git (887dda0ba) gives: 
---
Error: can only catch class objects derived from Exception in  safe code, not
'object.Throwable'
Error: undefined identifier __o1300
---

The reason for this are the artificial try/catch blocks generated around
statement.c:530.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Dec 02 2011
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7049


Jonathan M Davis <jmdavisProg gmx.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jmdavisProg gmx.com



PST ---
That's odd. That would imply that the try-catch blocks generated by
scope(failure) are using catch(Throwable) instead of catch(Exception), but
scope statements are supposed to be skipped when Errors are thrown, so there's
no reason for them be catching Throwable instead of Exception.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Dec 02 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7049


hsteoh quickfur.ath.cx changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |hsteoh quickfur.ath.cx
         Resolution|                            |WORKSFORME



Seems to be fixed in git HEAD. To prove that it actually works, I expanded the
test code a bit:

----------
import std.stdio;
int count = 0;
 safe void foo() {
  scope (failure) { count++; }
  scope (failure) { count++; }
  throw new Exception("failed");
}
void main() {
    try {
        foo();
    } catch(Exception e) {
    }
    writeln(count);
}
----------

Output:
2

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 19 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7049


Andrej Mitrovic <andrej.mitrovich gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |andrej.mitrovich gmail.com



20:20:06 PDT ---
It would be great to add these test-cases of worksforme bugs to the test-suite,
if they're not already there.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 19 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7049




https://github.com/D-Programming-Language/dmd/pull/2484

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 19 2013
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7049




Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/18af82ec425cfc2d5fc86f78648c02a9c6efcbd0
Add test case for issue 7049.

https://github.com/D-Programming-Language/dmd/commit/85c033631b6512163d7bf871da49c12a25651605


Add test case for issue 7049.

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