Bug 7324 – Access Violation when printing struct with union

Status
RESOLVED
Resolution
DUPLICATE
Severity
major
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-01-19T20:04:00Z
Last change time
2012-03-25T03:18:02Z
Assigned to
nobody
Creator
andrej.mitrovich

Comments

Comment #0 by andrej.mitrovich — 2012-01-19T20:04:35Z
import std.stdio; struct JSONValue { union { string str; long integer; real floating; JSONValue[string] object; JSONValue[] array; } int type; } void main() { JSONValue foo; foo.str = "a"; // remove to avoid access violation JSONValue bar; bar.object["foo"] = foo; writeln(bar.object["foo"]); // object.Error: Access Violation } This is taken from std.json, which suffers from these segfaults when you try to print out the 'object' field. Using `foreach (key, val)` works fine though.
Comment #1 by k.hara.pg — 2012-03-25T03:18:02Z
*** This issue has been marked as a duplicate of issue 7230 ***