www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 21794] New: Internal compiler assertion

https://issues.dlang.org/show_bug.cgi?id=21794

          Issue ID: 21794
           Summary: Internal compiler assertion
           Product: D
           Version: D2
          Hardware: All
               URL: http://dlang.org/
                OS: All
            Status: NEW
          Severity: major
          Priority: P3
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: eyal weka.io

This program triggers an internal compiler assertion (when assertions are
enabled in dmd itself):

  void f(void* p) {
      const x = cast(ulong)p;
  }

  pragma(msg, f(null));

Specifically, the assignment goes thru:

  private void setValue(VarDeclaration vd, Expression newval) {
     ...
    assert((vd.storage_class & (STC.out_ | STC.ref_)) ?
isCtfeReferenceValid(newval) : isCtfeValueValid(newval));
     ...
  }

and isCtfeValueValid has:

        case TOK.null_:
            return tb.ty == Tnull    ||
                   tb.ty == Tpointer ||
                   tb.ty == Tarray   ||
                   tb.ty == Taarray  ||
                   tb.ty == Tclass   ||
                   tb.ty == Tdelegate;

which returns false, because tb.ty is Tuns64.

--
Apr 03 2021