[Issue 12681] New: Rewrite rule prevents unique detection

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Tue Apr 29 14:51:44 PDT 2014


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: nobody at puremagic.com
          Reporter: bugzilla at digitalmars.com

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.

--


More information about the Digitalmars-d-bugs mailing list