Bug 10666 – Appender does not work with a RefCounted type
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-07-18T06:59:59Z
Last change time
2020-03-21T03:56:42Z
Assigned to
No Owner
Creator
Andrej Mitrovic
Comments
Comment #0 by andrej.mitrovich — 2013-07-18T06:59:59Z
-----
import std.array;
import std.typecons;
struct T { }
struct S
{
RefCounted!T data;
}
void main()
{
Appender!(S[]) arr;
arr.put(S());
}
-----
2.064:
$ dmd test.d
> C:\dmd-git\dmd2\windows\bin\..\..\src\phobos\std\array.d(2287): Error: variable std.array.Appender!(S[]).Appender.put!(S).put.item has scoped destruction, cannot build closure
However there is another bug in earlier releases:
2.063:
$ dmd test.d
$ test.exe
On win32 this crashes with a dialog box:
-----
[Window Title]
test.exe
[Main Instruction]
test.exe has stopped working
[Content]
A problem caused the program to stop working correctly. Please close the program.
[Close the program] [Debug the program]
-----
I've traced down the first version that crashes:
2.053:
> Crash
Earlier releases simply have an assertion failure:
2.052:
> [email protected](2351): Assertion failure
The code which failed there is:
-----
assert(RefCounted._store._count > 0);
-----
Comment #1 by k.hara.pg — 2013-09-10T18:05:31Z
(In reply to comment #0)
> 2.064:
> $ dmd test.d
> > C:\dmd-git\dmd2\windows\bin\..\..\src\phobos\std\array.d(2287): Error: variable std.array.Appender!(S[]).Appender.put!(S).put.item has scoped destruction, cannot build closure
The error reporting is a rejects-valid compiler bug.
https://github.com/D-Programming-Language/dmd/pull/2548
Comment #2 by k.hara.pg — 2013-09-10T18:07:31Z
(In reply to comment #1)
> (In reply to comment #0)
> > 2.064:
> > $ dmd test.d
> > > C:\dmd-git\dmd2\windows\bin\..\..\src\phobos\std\array.d(2287): Error: variable std.array.Appender!(S[]).Appender.put!(S).put.item has scoped destruction, cannot build closure
>
> The error reporting is a rejects-valid compiler bug.
>
> https://github.com/D-Programming-Language/dmd/pull/2548
After the compiler fix applied, the OP code with runtime crash will reproduce.
Comment #3 by github-bugzilla — 2013-09-14T23:50:31Z
Is there anything left of this bug to fix before closing it?
Comment #5 by andrej.mitrovich — 2013-10-07T07:35:23Z
(In reply to comment #4)
> Is there anything left of this bug to fix before closing it?
Yes, this runtime bug has to be fixed:
core.exception.InvalidMemoryOperationError
Comment #6 by andrej.mitrovich — 2013-10-07T07:36:53Z
However it shouldn't be filed as a regression anymore, fixing that.