[Issue 3049] New: ICE(cod4.c) or segfault: Array operation on void[] array

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Jun 3 16:17:05 PDT 2009


http://d.puremagic.com/issues/show_bug.cgi?id=3049

           Summary: ICE(cod4.c) or segfault: Array operation on void[]
                    array
           Product: D
           Version: 1.045
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: diagnostic, ice-on-invalid-code, patch
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla at digitalmars.com
        ReportedBy: clugdbug at yahoo.com.au


Array operations involving void[] can either ICE in the backend, segfault in
the front-end, or generate error messages without line numbers, which refer to
compiler-generated code. All have the same root cause: such operations are
nonsensical.

PATCH(tested on DMD1.045+D2.030): Add this code to the start of
BinExp::arrayOp(Scope *) in arrayop.c.
---
    if (type == Type::terror) { return this; }
    if (type->toBasetype()->nextOf()->toBasetype()->ty==Tvoid) {
        error("Cannot perform array operations on void[] arrays");
        return this;
    }
---

// TEST CASE 1: error message with no line number, referring to 
// compiler-generated code. The error is so unhelpful, it might
// as well be an ICE.
// Error: 'p0[p]' is not of arithmetic type, it is a const(void)
// Error: expression -(p0[p]) is void and has no value

void bar(){
  void [] x;
  x[] = -x[];
}

// TEST CASE 2: ICE(backend/cod4.c 353). On D1, it is another 
// error message with no line number
void foo(T)() {
   T[] a;
   a[] = -a[];
}
void main(){
 foo!(void)();
}

// Test case 3: segfault D1 + D2
typedef void car;
void baz(){
  int [] x;
  car [] y;
  y[] = -x[];
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list