[Issue 16081] New: CTFE mistakes &arr for arr in cast

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Thu May 26 15:09:08 PDT 2016


          Issue ID: 16081
           Summary: CTFE mistakes &arr for arr in cast
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: ag0aep6g at gmail.com

Encountered by Era Scarecrow in D.learn:

size_t f()
  size_t[] arr = [13];
  return *(cast(size_t*) &arr);

void main()
    import std.stdio;
    enum ct = f();
    auto rt = f();
    writeln(ct, " ", rt);

Prints: "13 1".

The expected value is 1 for both. A "not supported" error during CTFE would
also be acceptable, as happens when &arr is assigned to a variable first. Looks
like CTFE mistakes &arr for arr here.


More information about the Digitalmars-d-bugs mailing list