Bug 14838 – [REG 2.066] Wrong attribute inference for auto-generated class destructor with static array of non-POD type

Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2015-07-27T19:27:00Z
Last change time
2017-07-17T06:48:28Z
Keywords
pull, rejects-valid
Assigned to
code
Creator
sludwig
See also
https://issues.dlang.org/show_bug.cgi?id=8955

Comments

Comment #0 by sludwig — 2015-07-27T19:27:55Z
When a class contains a field that is a static array of a type that has a destructor, the attributes for the auto-generated class destructor are not correctly inferred and it fails to compile: --- struct Array(T) { ~this() {} } class Test { Array!int[1] array; } --- Error: pure function 'test.Test.~this' cannot call impure function 'object.TypeI nfo.destroy' test.d(2): Error: safe function 'test.Test.~this' cannot call system function 'o bject.TypeInfo.destroy' test.d(2): Error: @nogc function 'test.Test.~this' cannot call non-@nogc functio n 'object.TypeInfo.destroy' test.d(2): Error: 'object.TypeInfo.destroy' is not nothrow test.d(2): Error: destructor 'test.Test.~this' is nothrow yet may throw
Comment #1 by ag0aep6g — 2015-07-28T18:54:32Z
This is a regression in 2.066. Digger says it's been introduced by https://github.com/D-Programming-Language/dmd/pull/3301
Comment #2 by code — 2015-07-29T10:00:02Z
*** Issue 14839 has been marked as a duplicate of this issue. ***
Comment #3 by code — 2015-07-29T10:03:48Z
The problem is the TypeInfo.destroy call in buildDtor [¹]. We need to replace it with an attribute correct replacement. [¹]: https://github.com/D-Programming-Language/dmd/blob/3b82f08badcafc7cf373be2182f4b3f5eb5db3b9/src/clone.c#L931
Comment #4 by code — 2015-07-29T10:36:17Z
The bug also exists for struct dtors. struct Array(T) { ~this() {} } struct Test { Array!int[1] array; }
Comment #5 by code — 2015-07-29T10:37:04Z
And struct postblits. struct Array(T) { this(this) @safe {} } struct Test { Array!int[1] array; } ---- bug2.d(2): Error: safe function 'bug2.Test.__fieldPostblit' cannot call system function 'object.TypeInfo_StaticArray.postblit' ----
Comment #6 by k.hara.pg — 2015-07-29T10:45:20Z
(In reply to Martin Nowak from comment #3) > The problem is the TypeInfo.destroy call in buildDtor [¹]. > We need to replace it with an attribute correct replacement. > > [¹]: > https://github.com/D-Programming-Language/dmd/blob/ > 3b82f08badcafc7cf373be2182f4b3f5eb5db3b9/src/clone.c#L931 Yes. I had missed that in the PR 3301. https://github.com/D-Programming-Language/dmd/pull/4845
Comment #7 by github-bugzilla — 2015-07-30T09:34:26Z
Commits pushed to stable at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/d167403e777bcf91c50a7fd8eedf5100ac1ab50d fix Issue 14838 - Wrong attribute inference for auto-generated class destructor with static array of non-POD type https://github.com/D-Programming-Language/dmd/commit/7e531002058efa96e24e953ed2292cba6379e90f Merge pull request #4845 from 9rnsr/fix14838 [REG 2.066] Issue 14838 - Wrong attribute inference for auto-generated class destructor with static array of non-POD type
Comment #8 by github-bugzilla — 2015-07-30T12:05:52Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/d167403e777bcf91c50a7fd8eedf5100ac1ab50d fix Issue 14838 - Wrong attribute inference for auto-generated class destructor with static array of non-POD type https://github.com/D-Programming-Language/dmd/commit/7e531002058efa96e24e953ed2292cba6379e90f Merge pull request #4845 from 9rnsr/fix14838
Comment #9 by k.hara.pg — 2015-08-04T02:54:57Z
*** Issue 14239 has been marked as a duplicate of this issue. ***