https://issues.dlang.org/show_bug.cgi?id=17770

          Issue ID: 17770
           Summary: Null pointer access in CTFE code
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Windows
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nob...@puremagic.com
          Reporter: slud...@outerproduct.org

Compiling the following snippet with DMD 2.076.0-b1 yields:

object.Error@(0): Access Violation
----------------
0x0042FF45

Earlier compiler versions produce similar errors.

---
struct S { T*[] nodes; }
struct T { string name; }

S foo(string text)
{
    T*[] ret;
    while (text.length) {
        auto n = new T;
        n.name = text;
        text = text[1 .. $];
        ret ~= n;
    }
    return S(ret);
}

string bar(in S doc)
{
    foreach (n; doc.nodes)
        baz(n);
    return null;
}

void baz(in T* node)
{
    switch (node.name) {
        default:
        case "|":
            break;
    }
}

static const n = foo("xx");
enum b = bar(n);
---

--

Reply via email to