www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - struct forward reference

reply "Chris Miller" <chris dprogramming.com> writes:
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.
Feb 07 2006
next sibling parent reply Fredrik Olsson <peylow treyst.se> writes:
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; }
Feb 08 2006
parent "Chris Miller" <chris dprogramming.com> writes:
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.
Feb 08 2006
prev sibling next sibling parent reply Stewart Gordon <smjg_1998 yahoo.com> writes:
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.
Feb 08 2006
parent "Jarrett Billingsley" <kb3ctd2 yahoo.com> writes:
"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.
Feb 08 2006
prev sibling parent Thomas Kuehne <thomas-dloop kuehne.cn> writes:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

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 -----BEGIN PGP SIGNATURE----- iD8DBQFD7bkU3w+/yD4P9tIRAlAxAJ9s9tRf4XLqxFuSgZUpgGEielpJ8QCgw3+2 Q3iUGr0cAA5whMQEFNQLUHk= =xyBR -----END PGP SIGNATURE-----
Feb 11 2006