www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 1093] New: DMD doesn't generate correct try block code

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

           Summary: DMD doesn't generate correct try block code
           Product: D
           Version: 1.010
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: davidl 126.com


void testfunc()
{
        static int i;
        i++;
        scope(exit) printf( "i=%d\n", --i);
        if (i==10)
                throw new Exception(``);
        testfunc;
}
void main()
{
        try
        {
                testfunc;
        }
        finally
        {}
        printf(`hello`);
}


-- 
Apr 04 2007
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1093





------- Comment #1 from braddr puremagic.com  2007-04-05 02:24 -------
What happens when you run it?  What do you expect it to do that it's not doing?

When I run it I see it print 10 down to 1 and then print Error:, exactly as I'd
expect (though a linefeed would be nice, that's not what I suspect you're
reporting).

I suspect what you're expecting is that the finally block doesn't stop the
throw from propagating.  If that's what you expect you should have used 'catch'
rather than 'finally'.

IE, there's no bug here as far as I can tell.  If there is, you'll need to be
much more informative about what this report is about.  In the future, please
try to include that type of information with your report so that less guessing
is required to evaluate the bug report.


-- 
Apr 05 2007
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1093


thomas-dloop kuehne.cn changed:

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




------- Comment #2 from thomas-dloop kuehne.cn  2007-04-05 03:29 -------
Use "catch" instead of "finally" if you like to see "hello" or put the printf 
inside the finally scope.


-- 
Apr 05 2007
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1093





------- Comment #3 from thomas-dloop kuehne.cn  2007-04-05 05:26 -------
(In reply to comment #1)
 When I run it I see it print 10 down to 1 and then print Error:, exactly as 

 would be nice, that's not what I suspect you're reporting).

Do you really see 10 .. 1 instead of 9 .. 0 ? --
Apr 05 2007
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1093





------- Comment #4 from braddr puremagic.com  2007-04-05 12:01 -------
Sorry, you're right, 9..0.


-- 
Apr 05 2007
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1093





------- Comment #5 from davidl 126.com  2007-04-09 04:06 -------
Oh, it's too common for me to think it does the same as other language, like
delphi
try finally in delphi does stop the propagating


-- 
Apr 09 2007