Issue 24878 - Forward referencing issue
Summary: Forward referencing issue
Status: NEW
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P3 normal
Assignee: No Owner
URL: http://dlang.org/
Keywords:
Depends on:
Blocks:
 
Reported: 2024-11-25 06:11 UTC by Manu
Modified: 2024-11-25 06:11 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Manu 2024-11-25 06:11:36 UTC
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.