April 14, 2005 Exceptions part 2: Incomplete objects | ||||
---|---|---|---|---|
| ||||
# /* # This example demonstrates that the dtors of incomplete # objects are called during a GC run. # */ # # import std.c.stdio; # import std.gc; # # class IC # { # this() # { # printf( "IC ctor\n" ); # throw new Exception( "IC Exception" ); # } # # ~this() # { # printf( "IC dtor\n" ); # } # } # # void main() # { # try # { # IC ic = new IC(); # printf( "success\n" ); # } # catch( Exception e ) # { # printf( "fail: %.*s\n", e.toString() ); # } # fullCollect(); # printf( "done\n" ); # } Output: IC ctor fail: IC Exception IC dtor done |
April 15, 2005 Re: Exceptions part 2: Incomplete objects | ||||
---|---|---|---|---|
| ||||
Posted in reply to Sean Kelly | -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Sean Kelly schrieb am Thu, 14 Apr 2005 05:39:32 +0000 (UTC): > # /* > # This example demonstrates that the dtors of incomplete > # objects are called during a GC run. > # */ > # > # import std.c.stdio; > # import std.gc; > # > # class IC > # { > # this() > # { > # printf( "IC ctor\n" ); > # throw new Exception( "IC Exception" ); > # } > # > # ~this() > # { > # printf( "IC dtor\n" ); > # } > # } > # > # void main() > # { > # try > # { > # IC ic = new IC(); > # printf( "success\n" ); > # } > # catch( Exception e ) > # { > # printf( "fail: %.*s\n", e.toString() ); > # } > # fullCollect(); > # printf( "done\n" ); > # } Known bug http://dstress.kuehne.cn/run/destructor_04.d Thomas -----BEGIN PGP SIGNATURE----- iD8DBQFCXx4B3w+/yD4P9tIRAn0zAJ0Wuqm4deW0v84PXtU5hcHcfTzTFwCfbFhP +Fna+zTWf5cXBc+c87J/+ok= =VCl/ -----END PGP SIGNATURE----- |
Copyright © 1999-2021 by the D Language Foundation