Given a struct S in A.d and a template T int B.d with a nested struct and S as its member: // file A.d: import B; struct S { } // file B.d: import A; struct T() { struct Nested { S member; } } ========================================= Compiling with dmd 1.005 on winXP: bud A Yields this: B.d(x): struct B.T!().T.Nested has forward references B.d(x): template instance B.T!() error instantiating But it compiles if... - you make 'Nested' an anonymous struct - you declare 'Nested' somewhere outside of 'T', even after the instantiation - you make 'member' a pointer or S a class - you change compile order, ie. 'bud B' - you put the instantiation below the declaration of S in A.d - you use dmd 0.177 (!) It still does not compile if 'Nested' is made a static struct.
Interesting. Neither dmd A.d B.d dmd B.d A.d shows the problem (trying it under Win98SE). But what puzzles me most is that in your attempt, the compiler prints "x" instead of a line number.
d-bugmail@puremagic.com schrieb: > http://d.puremagic.com/issues/show_bug.cgi?id=945 > > > smjg@iname.com changed: > > What |Removed |Added > ---------------------------------------------------------------------------- > CC| |smjg@iname.com > Keywords| |rejects-valid > > > > > ------- Comment #1 from smjg@iname.com 2007年02月10日 10:30 ------- > Interesting. Neither > > dmd A.d B.d > dmd B.d A.d > > shows the problem (trying it under Win98SE). But what puzzles me most is that > in your attempt, the compiler prints "x" instead of a line number. > > I just used "x" because I didn ́t want to count the line numbers and the lines are shifted in my bug report. But the behaviour of "dmd A.d B.d" and vice versa is very interesting, cause manually invoking the compiler with theses lines runs for me too (thanks for the hint!). But both Code::Blocks and 'bud' failed. Under Code::Blocks with full command line logging enabled it says: dmd.exe -I\include -IC:\dmd\src\phobos -c D:\Dev\Projects\DError\B.d -ofobj\Release\B.obj dmd.exe -I\include -IC:\dmd\src\phobos -c D:\Dev\Projects\DError\A.d -ofobj\Release\A.obj dmd.exe bin\Release\DError.exe obj\Release\B.obj obj\Release\A.obj phobos.lib B.d(6): struct B.T!().T.Nested has forward references B.d(11): template instance B.T!() error instantiating Process terminated with status 1 (0 minutes, 0 seconds) 2 errors, 0 warnings I tried to reproduce the error Code::Blocks ran into, but running the same lines from a batch file works! The same error appears by doing 'bud A' (but not 'bud B'!). Can anybody explain this strange behaviour?
d-bugmail@puremagic.com schrieb: > http://d.puremagic.com/issues/show_bug.cgi?id=945 > > > smjg@iname.com changed: > > What |Removed |Added > ---------------------------------------------------------------------------- > CC| |smjg@iname.com > Keywords| |rejects-valid > > > > > ------- Comment #1 from smjg@iname.com 2007年02月10日 10:30 ------- > Interesting. Neither > > dmd A.d B.d > dmd B.d A.d > > shows the problem (trying it under Win98SE). But what puzzles me most is that > in your attempt, the compiler prints "x" instead of a line number. > > This is very embarrissing, but I just forgot the instantiation of the template! It should be: // file A.d: import B; struct S { } // file B.d: import A; struct T() { struct Nested { S member; } } alias T!() instance; // <- add this line!! This should finally reproduce the error!
Please don't blindly quote the entire message when replying. It's bad enough on any old newsgroup, but in this instance it clutters up Bugzilla. (In reply to comment #2) > I just used "x" because I didn ́t want to count the line numbers and the > lines are shifted in my bug report. Then leave the compiler output alone. It sometimes helps to add comments to posted code to indicate line numbers.
I have rediscovered this bug while working on a large and very template-heavy project of mine. The project is currently held up by this (and possibly other) template forwarding bugs, and so it would be really appreciated if this bug was fixed in the not too distant future. Thanks ;-)
Here's a patch that invokes the missing semantics. It also fixes issue #1055 Index: struct.c =================================================================== --- struct.c (revision 421) +++ struct.c (working copy) @@ -178,6 +178,8 @@ error("cannot have field %s with same struct type", v->toChars()); } #endif + if (ts->sym->sizeok != 1 && ts->sym->scope) + ts->sym->semantic(NULL); if (ts->sym->sizeok != 1) {
changeset 478
Fixed DMD1.061 and DMD2.046.
AltStyle によって変換されたページ (->オリジナル) / アドレス: モード: デフォルト 音声ブラウザ ルビ付き 配色反転 文字拡大 モバイル