www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 16081] New: CTFE mistakes &arr for arr in cast


          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 puremagic.com
          Reporter: ag0aep6g gmail.com

Encountered by Era Scarecrow in D.learn:
http://forum.dlang.org/post/mzzpcdzuovajqygueqwc forum.dlang.org

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.

May 26 2016