www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 15945] New: sizeof on an invalid type seems to compile.

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

          Issue ID: 15945
           Summary: sizeof on an invalid type seems to compile.
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: major
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: john.loughran.colvin gmail.com

size_t foo(T)()
{
    return T[0].sizeof;
}
void main()
{
    auto a = foo!(ubyte[])();
    assert(a == 1);
}

Seems like either that shouldn't compile, or (maybe?) the assert should pass.
Currently, it compiles and the assert fails.

--
Apr 21 2016