Bug 14595 – [REG2.066] RefCounted data corrupted when in an AA

Status
RESOLVED
Resolution
DUPLICATE
Severity
regression
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2015-05-17T02:04:08Z
Last change time
2020-02-08T08:55:22Z
Keywords
wrong-code
Assigned to
No Owner
Creator
Vladimir Panteleev
See also
https://issues.dlang.org/show_bug.cgi?id=17145

Comments

Comment #0 by dlang-bugzilla — 2015-05-17T02:04:08Z
/////////////// test.d ////////////// import std.typecons; alias ObjectWriter = RefCounted!int; ObjectWriter[string] writers; void main() { writers[null] = ObjectWriter(42); auto pwriter = null in writers; assert(*pwriter == 42); } ///////////////////////////////////// Assertion fails on Linux/64. Introduced in https://github.com/D-Programming-Language/dmd/pull/3672
Comment #1 by dlang-bugzilla — 2015-05-17T03:08:37Z
I have reduced the above to the following code: //////////// test.d //////////// struct S { this(int) { } bool okToDestroy; ~this() { assert(okToDestroy); } } S[string] aa; void main() { aa[null] = S(42); aa[null].okToDestroy = true; } //////////////////////////////// But this reduction does not manifest as a regression.
Comment #2 by dlang-bugzilla — 2015-05-17T03:38:41Z
Alternative reduction: //////// test.d //////// struct S { int* count; this(int) { count = new int; *count = 1; } this(this) { ++count; } ~this() { --*count; } } S[string] aa; void main() { aa[null] = S(42); auto p = null in aa; assert(*p.count); } //////////////////////// 2.064.2: works 2.065.0: ICE 2.066.1: assert fails
Comment #3 by dlang-bugzilla — 2015-05-17T03:40:21Z
(In reply to Vladimir Panteleev from comment #2) > ++count; Should be ++*count
Comment #4 by k.hara.pg — 2015-06-01T12:24:28Z
The root problem is same with issue 14321, and it's already fixed in git-head (2.068a). *** This issue has been marked as a duplicate of issue 14321 ***