www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 12744] New: auto ref crashes DMD on ASSERT

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

          Issue ID: 12744
           Summary: auto ref crashes DMD on ASSERT
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: critical
          Priority: P1
         Component: DMD
          Assignee: nobody puremagic.com
          Reporter: tomerfiliba gmail.com

This little snippet crashes the compiler (DMD 2.065) on an ASSERT:

    dmd: mtype.c:9958: void Parameter::toDecoBuffer(OutBuffer*): Assertion `0'
failed.

============
void f(int x, out int y) {}

void g(alias F)(auto ref ParameterTypeTuple!F args) {}

void main() {
    int y;
    g!f(1, y);
}
============

The issue is that "auto ref" adds 'ref' to y as well, causing a 'ref out' to be
inferred, which then fails on an assert in the compiler. Took me half a day to
hunt down.

--
May 13 2014