Thread overview | |||||||
---|---|---|---|---|---|---|---|
|
January 24, 2006 roll-up of old bugs: auto dtor not called on exception | ||||
---|---|---|---|---|
| ||||
Seems the last few DMD releases have fixed most of the problems I've had in the past (including the template bugs--thanks Walter!). A few remain however, and since I'm not sure they're all in DStress, I'm reposting them here. C:\code\d\bugs>type 101_1.d // This demonstrates incorrect behavior for auto class // construction. If an exception is thrown out of a // class ctor then it is an incomplete object and its // dtor should not be called. import std.c.stdio; auto class AutoClass { public: this() { printf( "ctor\n" ); throw new Exception( "" ); } ~this() { printf( "dtor\n" ); } } void main() { try { auto AutoClass c = new AutoClass(); } catch( Exception e ) { printf( "caught\n" ); } printf( "continue\n" ); } C:\code\d\bugs>dmd 101_1.d C:\bin\dmd\bin\..\..\dm\bin\link.exe 101_1,,,user32+kernel32/noi; C:\code\d\bugs>101_1 ctor caught continue dtor C:\code\d\bugs> |
January 24, 2006 correction: bug is 'dtor for auto object is called on incomplete object' | ||||
---|---|---|---|---|
| ||||
Posted in reply to Sean Kelly | Sean Kelly wrote:
> Seems the last few DMD releases have fixed most of the problems I've had in the past (including the template bugs--thanks Walter!). A few remain however, and since I'm not sure they're all in DStress, I'm reposting them here.
>
> C:\code\d\bugs>type 101_1.d
> // This demonstrates incorrect behavior for auto class
> // construction. If an exception is thrown out of a
> // class ctor then it is an incomplete object and its
> // dtor should not be called.
>
>
> import std.c.stdio;
>
>
> auto class AutoClass
> {
> public:
> this()
> {
> printf( "ctor\n" );
> throw new Exception( "" );
> }
>
> ~this()
> {
> printf( "dtor\n" );
> }
> }
>
>
> void main()
> {
> try
> {
> auto AutoClass c = new AutoClass();
> }
> catch( Exception e )
> {
> printf( "caught\n" );
> }
> printf( "continue\n" );
> }
> C:\code\d\bugs>dmd 101_1.d
> C:\bin\dmd\bin\..\..\dm\bin\link.exe 101_1,,,user32+kernel32/noi;
>
> C:\code\d\bugs>101_1
> ctor
> caught
> continue
> dtor
>
> C:\code\d\bugs>
|
January 25, 2006 Re: correction: bug is 'dtor for auto object is called on incomplete object' | ||||
---|---|---|---|---|
| ||||
Posted in reply to Sean Kelly Attachments: | Sean Kelly schrieb am 2006-01-24: > Sean Kelly wrote: >> Seems the last few DMD releases have fixed most of the problems I've had in the past (including the template bugs--thanks Walter!). A few remain however, and since I'm not sure they're all in DStress, I'm reposting them here. >> >> C:\code\d\bugs>type 101_1.d >> // This demonstrates incorrect behavior for auto class >> // construction. If an exception is thrown out of a >> // class ctor then it is an incomplete object and its >> // dtor should not be called. >> >> >> import std.c.stdio; >> >> >> auto class AutoClass >> { >> public: >> this() >> { >> printf( "ctor\n" ); >> throw new Exception( "" ); >> } >> >> ~this() >> { >> printf( "dtor\n" ); >> } >> } >> >> >> void main() >> { >> try >> { >> auto AutoClass c = new AutoClass(); >> } >> catch( Exception e ) >> { >> printf( "caught\n" ); >> } >> printf( "continue\n" ); >> } >> C:\code\d\bugs>dmd 101_1.d >> C:\bin\dmd\bin\..\..\dm\bin\link.exe 101_1,,,user32+kernel32/noi; >> >> C:\code\d\bugs>101_1 >> ctor >> caught >> continue >> dtor >> >> C:\code\d\bugs> Extended http://dstress.kuehne.cn/run/destructor_04.d to http://dstress.kuehne.cn/run/a/auto_14_A.d http://dstress.kuehne.cn/run/a/auto_14_B.d Thomas |
Copyright © 1999-2021 by the D Language Foundation