[D1] assert failure expression.c

%u e at ee.com
Sat Oct 9 10:18:31 PDT 2010


Incomplete mixin expression + char[] to char assignment = crash :)

--
char[] foo()
{
  char[2] res = "1 ";
  res[1] = ";"; // should be a char
  return res;
}

struct S(T)
{
  int i = mixin( foo() ); // incomplete mixin expression
}

S!(int) s;
--
Assertion failure: '0' on line 1342 in file 'expression.c'

And while you are reading this, could you maybe tell me why this needs a .dup?
--
char[] bar()
{
  char[8] res = "int i=0;";
  return res.dup;// without: main.d(/here/): Error: escaping reference to
local res
}
mixin ( bar() );
--





More information about the Digitalmars-d-learn mailing list