digitalmars.D.bugs - [Issue 14902] New: Temporaries in argument expressions not properly
- via Digitalmars-d-bugs (65/65) Aug 10 2015 https://issues.dlang.org/show_bug.cgi?id=14902
https://issues.dlang.org/show_bug.cgi?id=14902 Issue ID: 14902 Summary: Temporaries in argument expressions not properly destructed on throw (argprefix) Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: major Priority: P1 Component: dmd Assignee: nobody puremagic.com Reporter: kinke gmx.net Created attachment 1540 --> https://issues.dlang.org/attachment.cgi?id=1540&action=edit Test cases There are still major issues wrt. proper destruction of temporaries in expression trees in case there are throws. These tests came up when verifying an ongoing LDC implementation. The attached file allows you to test 5 cases, by passing an arg in [1,5]. Case 1 doesn't feature any throw in the function argument expressions, but features multiple objects with throwing dtors. Case 2 throws in its last argument expression. The 3 preceeding temporaries should be destructed. Case 3 is similar to case 2, but 2 of the 3 temporaries throw in their dtors. I guess this should result in all temporary dtors being called (always) and building up an exception chain. Case 4 already throws in its 2nd argument expression; the single preceeding temporary doesn't throw in its dtor. Case 5 does throw. Identical results with both DMD 2.067.1 and DMD 2.068-rc1 for Win32: 1) Fine - regular throw in callee, args have been implicitly moved into callee params, callee destructs them. The exceptions in the dtors result in an exception chain: Test 1: Constructing a Constructing b Constructing c Constructing d Destroying a Destroying b Destroying c Destroying d object.Exception ..\dtor.d(26): foo()! object.Exception ..\dtor.d(16): dtor a object.Exception ..\dtor.d(16): dtor c 2&3) No temporaries destructed at all! Test 2&3: Constructing a Constructing b Constructing c object.Exception ..\dtor.d(22): make(d) 4) Fine, at last. Test 4: Constructing a Destroying a object.Exception ..\dtor.d(22): make(b) 5) CRASH at runtime! Test 5: Constructing Destroying a Destroying a ... <repetition until crash> --
Aug 10 2015