Thread overview
struct forward reference
Feb 07, 2006
Chris Miller
Feb 08, 2006
Fredrik Olsson
Feb 08, 2006
Chris Miller
Feb 08, 2006
Stewart Gordon
Feb 11, 2006
Thomas Kuehne
February 07, 2006
struct Foo { const Foo f; }


DMD 0.145 output on Windows:

test.d(1): struct test.Foo unable to resolve forward reference


Only seems to happen if it's const.
February 08, 2006
Chris Miller skrev:
> struct Foo { const Foo f; }
> 
> 
> DMD 0.145 output on Windows:
> 
> test.d(1): struct test.Foo unable to resolve forward reference
> 
> 
> Only seems to happen if it's const.

Would not this be recursive to infinity? Perhaps this is more in line what you want:
struct Foo { const Foo* f; }
February 08, 2006
Chris Miller wrote:
> struct Foo { const Foo f; }
> 
> DMD 0.145 output on Windows:
> 
> test.d(1): struct test.Foo unable to resolve forward reference
> 
> Only seems to happen if it's const.

Sounds like a regression to me.  So what happens if it isn't const?  It should be an error regardless.  Will have to investigate....

Stewart.

-- 
-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GCS/M d- s:- C++@ a->--- UB@ P+ L E@ W++@ N+++ o K-@ w++@ O? M V? PS- PE- Y? PGP- t- 5? X? R b DI? D G e++>++++ h-- r-- !y
------END GEEK CODE BLOCK------

My e-mail is valid but not my primary mailbox.  Please keep replies on the 'group where everyone may benefit.
February 08, 2006
On Wed, 08 Feb 2006 03:20:10 -0500, Fredrik Olsson <peylow@treyst.se> wrote:

> Chris Miller skrev:
>> struct Foo { const Foo f; }
>>   DMD 0.145 output on Windows:
>>  test.d(1): struct test.Foo unable to resolve forward reference
>>   Only seems to happen if it's const.
>
> Would not this be recursive to infinity? Perhaps this is more in line what you want:
> struct Foo { const Foo* f; }

Don't think so, not like it's actually adding to the struct's storage. More like a namespace thing or implying static as well.
February 08, 2006
"Stewart Gordon" <smjg_1998@yahoo.com> wrote in message news:dsclko$1c26$1@digitaldaemon.com...
> Sounds like a regression to me.  So what happens if it isn't const?  It should be an error regardless.

It still fails if the member is non-const.

Though, like Fredrik said, I would imagine that, since structs are value types, this should be illegal, because it would have to be a recursive structure - a Foo contains a Foo, which contains a Foo which contains a Foo.. perhaps this error message is the compiler's own special way of reporting this ;)  as

struct Foo
{
    [const] Foo* a;
}

Works.


February 11, 2006
Chris Miller schrieb am 2006-02-07:
> struct Foo { const Foo f; }
>
>
> DMD 0.145 output on Windows:
>
> test.d(1): struct test.Foo unable to resolve forward reference
>
>
> Only seems to happen if it's const.

Added to DStress as http://dstress.kuehne.cn/nocompile/s/struct_23_A.d http://dstress.kuehne.cn/nocompile/s/struct_23_B.d http://dstress.kuehne.cn/nocompile/s/struct_23_C.d http://dstress.kuehne.cn/nocompile/s/struct_23_D.d http://dstress.kuehne.cn/nocompile/s/struct_23_E.d http://dstress.kuehne.cn/run/s/struct_23_F.d http://dstress.kuehne.cn/run/s/struct_23_G.d

Thomas