www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 12863] New: Crash in cast_.d on OSX 10.9

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

          Issue ID: 12863
           Summary: Crash in cast_.d on OSX 10.9
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Mac OS X
            Status: NEW
          Severity: minor
          Priority: P1
         Component: DMD
          Assignee: nobody puremagic.com
          Reporter: tcdknutson gmail.com

Tested on OSX 10.9, this will cause a segfault in dmd 2.065 in `cast_.d`, where
there should be none (it should just return null)

```
interface Node {}
interface WhereCondition {}
interface Whereable {}

class Where
{
  Whereable      left; // lhs

  this(Whereable left ) {
    this.left = left;
  }
}

class Select : Whereable
{

  WhereCondition[] projection;

  this(WhereCondition[] projection...) {
    this.projection = projection;
  }

  Where where()
  {
    return new Where(this);
  }
}

class ATable
{
  Where where() {
    return (new Select(null)).where();
  }
}


void main() {
  auto users = new ATable();
  auto where = users.where();
  WhereCondition var = (cast(Select)where.left).projection[0];
  auto var2 = cast(Node) var;
}
```

Removing the last line (auto var2 = ...) will cause the crash not to happen,
which makes me think the issue is arising when casting to `Node` from type
WhereCondition.

--
Jun 05 2014