https://issues.dlang.org/show_bug.cgi?id=12681
Issue ID: 12681
Summary: Rewrite rule prevents unique detection
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: enhancement
Priority: P1
Component: DMD
Assignee: [email protected]
Reporter: [email protected]
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.
--