The code:
immutable int x = 42;
static struct S { immutable int *p; }
immutable s = new S(&x);
should work, but it fails because of the rewrite rule https://github.com/D-Programming-Language/dmd/blob/master/src/expression.c#L5066
/* Rewrite:
* new S(arguments)
* as:
* (((S* __newsl = new S()), (*__newsl = S(arguments))), __newsl)
*/
One avenue to fix this is to mark __newsl as unique, so that the conversion will work.
Comment #1 by k.hara.pg — 2014-04-30T01:53:45Z
> /* Rewrite:
> * new S(arguments)
> * as:
> * (((S* __newsl = new S()), (*__newsl = S(arguments))), __newsl)
> */
One easy way is to move the rewriting to glue layer (in old days I couldn't do it).