digitalmars.D - Bug found ??
- Thorsten Kiefer (49/49) Mar 03 2007 Hi,
Hi, the following code works fine : import std.stdio; import test4mod; char[] d_problem(T)(T x){ static if(is(T B == B[])) { return "[" ~ d_problem(x[0]) ~ "]"; } else { return "bla"; } } void main(char[][] args){ int[][] x = [[1,2,3]]; writefln("%s",d_problem(x)); } The outout is : [[bla]] If I split this into 2 files : import std.stdio; import test4mod; void main(char[][] args){ int[][] x = [[1,2,3]]; writefln("%s",d_problem(x)); } module test4mod; char[] d_problem(T)(T x){ static if(is(T B == B[])) { return "[" ~ d_problem(x[0]) ~ "]"; } else { return "bla"; } } If you run this progam, you get a "segmentation fault". A bug ? It can be corrected : import std.stdio; import test4mod; void main(char[][] args){ int[][] x = [[1,2,3]]; writefln("%s",d_problem(x)); } module test4mod; char[] d_problem(T)(T x){ static char[] a = "[",b = "]"; static if(is(T B == B[])) { return a ~ d_problem(x[0]) ~ b; } else { return "bla"; } } This works fine again.
Mar 03 2007