Thread overview | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
|
February 10, 2007 [Issue 945] New: template forward reference with named nested struct only | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=945 Summary: template forward reference with named nested struct only Product: D Version: 1.005 Platform: PC OS/Version: Windows Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: bugzilla@digitalmars.com ReportedBy: manuelk89@gmx.net BugsThisDependsOn: 340,810 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. -- |
February 10, 2007 [Issue 945] template forward reference with named nested struct only | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | 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. -- |
February 10, 2007 Re: [Issue 945] template forward reference with named nested struct only | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | 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?
|
February 10, 2007 Re: [Issue 945] template forward reference with named nested struct only | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | 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!
|
February 10, 2007 [Issue 945] template forward reference with named nested struct only | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=945 ------- Comment #4 from smjg@iname.com 2007-02-10 12:09 ------- 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. -- |
August 20, 2007 [Issue 945] template forward reference with named nested struct only | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=945 ------- Comment #5 from korslund@gmail.com 2007-08-20 07:56 ------- 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 ;-) -- |
March 27, 2010 [Issue 945] template forward reference with named nested struct only | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=945 Rainer Schuetze <r.sagitario@gmx.de> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |patch CC| |r.sagitario@gmx.de --- Comment #6 from Rainer Schuetze <r.sagitario@gmx.de> 2010-03-27 06:22:43 PDT --- 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) { -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
May 10, 2010 [Issue 945] template forward reference with named nested struct only | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=945 Walter Bright <bugzilla@digitalmars.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |bugzilla@digitalmars.com --- Comment #7 from Walter Bright <bugzilla@digitalmars.com> 2010-05-10 11:45:01 PDT --- changeset 478 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
May 18, 2010 [Issue 945] template forward reference with named nested struct only | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=945 Don <clugdbug@yahoo.com.au> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |clugdbug@yahoo.com.au Resolution| |FIXED --- Comment #8 from Don <clugdbug@yahoo.com.au> 2010-05-18 12:15:17 PDT --- Fixed DMD1.061 and DMD2.046. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
Copyright © 1999-2021 by the D Language Foundation