digitalmars.D.bugs - strange seg-v on reclusive call
This looks to me like a bug but I could be wrong. private import std.stdio; void Part(Rule[] inSet) { scope(failure) writef("===========\n"); { // dorp this blobk and things work Build!(Rule) tmp; insertUnUsed: foreach(r; inSet) if(r.users.length == 0) // drop this line and it runs { } } F( [new Rule, null, null, null, null]); // this works scope(failure) writef("+++++++++++++++\n"); Part([new Rule, null, null, null, null]); // this segv's scope(failure) writef("----------\n"); } void F(Rule[] r){} class Rule { Rule[] users; } alias void function(int) sighandler_t; extern (C) sighandler_t signal(int signum, sighandler_t handler); void main() { // convert sigsegv to excption signal(11,function void(int i){throw new Error("SEGV");}); Part([new Rule()]); } struct Build(T) { static const int step = 5; T[] a; int at = 0; void Insert(T t) { if(a.length <= at) a.length = at + step; a[at++] = t; } }
Sep 17 2007
Reply to Benjamin, this is definitely a code gen bug running with -O fixes it (on the current version). By looking at the ASM the only difference seems to be in the register assignments, possibly indicating an unassigned value bug (there is a register that is used without being assigned after that last statement). I'm posting a bug.
Sep 18 2007