[Issue 17770] New: Null pointer access in CTFE code
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Mon Aug 21 02:35:07 PDT 2017
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: nobody at puremagic.com
Reporter: sludwig at 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);
---
--
More information about the Digitalmars-d-bugs
mailing list