Mercurial > projects > dstress
view run/a/associative_array_19_D.d @ 1581:930dbd51f0cc
[Issue 1689] New: Segfaults for nested array allocation with GDC
<mariusmuja@gmail.com>
2007-11-24
http://d.puremagic.com/issues/show_bug.cgi?id=1689
author | thomask |
---|---|
date | Fri, 22 Feb 2008 07:54:39 +0000 |
parents | b8c0195059d9 |
children |
line wrap: on
line source
// $HeadURL$ // $Date$ // $Author$ // @author@ Sebastian Beschke <s.beschke@gmx.de> // @date@ 2005-03-25 // @uri@ http://www.digitalmars.com/pnews/read.php?server=news.digitalmars.com&group=digitalmars.D.bugs&artnum=6821 // @WARNING@ direct access to Phobos' GC module dstress.run.a.associative_array_19_D; import std.gc; union Key{ char x; ubyte[4] y; } class Payload { this(Key value) { value.x += 1; _value = value; } Key value() { return _value; } Key _value; } int main(){ Payload[Key] aa; Key[] allKeys; static Key a = { 'a' }; static Key b = { 'b' }; static Key c = { 'c' }; allKeys ~= a; allKeys ~= b; allKeys ~= c; foreach(Key key; allKeys) { aa[key] = new Payload(key); } for(size_t step = 0; step < 10000; step++){ foreach(Key key; allKeys) { if(!(key in aa)){ assert(0); } Payload p = aa[key]; if(p.value.x != key.x + 1){ assert(0); } } std.gc.fullCollect(); } return 0; }