Bug 8949 – [CTFE] ICE(ctfeexpr.c) copying a reference to a null AA

Status
RESOLVED
Resolution
WORKSFORME
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-11-02T21:07:00Z
Last change time
2014-04-11T00:39:57Z
Keywords
CTFE, ice
Assigned to
nobody
Creator
zan77137

Comments

Comment #0 by zan77137 — 2012-11-02T21:07:40Z
This code doesn't work: string test() { import std.csv; static struct Layout { string a, b; } static struct MapData { string[string] map; } MapData md; foreach (data; csvReader!Layout("a,")) { md.map[data.a] = data.b; } return md.map.get("b", null); } void main() { //import std.stdio; //writeln(test()); // <- OK pragma(msg, test()); // <- NG } Result: main.d(9): Error: Internal Compiler Error: CTFE literal Layout(['a'],null).b Assertion failure: '0' on line 353 in file 'ctfeexpr.c'
Comment #1 by clugdbug — 2012-11-05T11:49:39Z
Reduced test case: struct S { int[int] a; } void baz(ref int[int] x) { auto m = x.dup; } int bar() { S s; baz(s.a); return 1; } static assert(bar()); --- Applies to any case where you pass an AA by reference _when it is null_, and then duplicate it. <sigh> This is the bizarre "magic null" semantics that happen only with AAs. It causes dozens of special cases.
Comment #2 by k.hara.pg — 2014-04-11T00:39:57Z
The original case has worked from 2.063. The reduced test case in comment#1 works from 2.066 git-head, because AA implementation is changed to UFCS style.