Bug 17505 – [REG2.075] @safe constructor requires the deconstructor to be safe as well

Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2017-06-15T00:20:00Z
Last change time
2017-08-07T13:16:48Z
Assigned to
nobody
Creator
greensunny12

Comments

Comment #0 by greensunny12 — 2017-06-15T00:20:53Z
cat > main.d << CODE struct Array { int[] _payload; ~this() { import core.stdc.stdlib : free; free(_payload.ptr); } } class Scanner { Array arr; this() @safe {} } CODE $ dmd -main main.d(14): Error: @safe constructor 'main.Scanner.this' cannot call @system destructor 'main.Scanner.~this'
Comment #1 by code — 2017-06-17T03:12:46Z
Introduced by https://github.com/dlang/dmd/pull/6816 Also manifestates in libasync https://github.com/etcimon/libasync/blob/a56cf33720731de717ef5d6c5f1c0d51341da145/source/libasync/events.d#L57. ---- source/libasync/events.d(57,2): Error: destructor 'libasync.events.EventLoop.~this' is not nothrow source/libasync/events.d(57,2): Error: nothrow constructor 'libasync.events.EventLoop.this' may throw ----
Comment #2 by greeenify — 2017-06-17T03:19:21Z
FYI have you seen Cybershadow's comment? https://github.com/dlang/dmd/pull/6816#issuecomment-307657520 And his reduced test case for the regression in libasync? struct S { ~this() {} } class C { S s; this() nothrow {} }
Comment #3 by code — 2017-06-17T08:32:44Z
(In reply to greenify from comment #2) > FYI have you seen Cybershadow's comment? > https://github.com/dlang/dmd/pull/6816#issuecomment-307657520 Ah thanks, libasync is a duplicate of issue 17494, does have the nothrow, not the `@safe` issue.
Comment #4 by github-bugzilla — 2017-06-17T10:16:17Z
Commit pushed to master at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/558773e64d42d56ad02970adfdc1371311ca3291 add test cases for existing production code - fixes Issues 17494, 17505, 17506
Comment #5 by github-bugzilla — 2017-08-07T13:16:48Z
Commit pushed to newCTFE at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/558773e64d42d56ad02970adfdc1371311ca3291 add test cases for existing production code