Summary: Access Violation when printing struct with union
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: major
          Priority: P2
         Component: DMD

--- Comment #0 from Andrej Mitrovic <> 2012-01-19 
20:04:35 PST ---
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.

Configure issuemail:
------- You are receiving this mail because: -------

Reply via email to