www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 24878] New: Forward referencing issue

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

          Issue ID: 24878
           Summary: Forward referencing issue
           Product: D
           Version: D2
          Hardware: All
               URL: http://dlang.org/
                OS: All
            Status: NEW
          Severity: normal
          Priority: P3
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: turkeyman gmail.com

struct Container(T)
{
    // T.sizeof/alignof causes circular reference!
    enum AllocAlignment = T.sizeof;

    T* ptr;
}

struct Test
{
    Container!Test test;
}

error : struct `main.Test` no size because of forward reference
error : template instance `main.Container!(Test)` error instantiating


Checking T.sizeof causes a forward referencing error; but it doesn't need to
evaluate that enum to determine the size of `Container!T` which has a know-able
size with no T knowledge... evaluation should be deferred.

--
Nov 24