www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 945] New: template forward reference with named nested struct only

reply d-bugmail puremagic.com writes:
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.


-- 
Feb 10 2007
next sibling parent reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=945


smjg iname.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |smjg iname.com
           Keywords|                            |rejects-valid





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.


-- 
Feb 10 2007
next sibling parent =?UTF-8?B?TWFudWVsIEvDtm5pZw==?= <manuelk89 gmx.net> writes:
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
 
 
 
 

 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?
Feb 10 2007
prev sibling parent =?ISO-8859-15?Q?Manuel_K=F6nig?= <manuelk89 gmx.net> writes:
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
 
 
 
 

 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!
Feb 10 2007
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=945






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.


 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. --
Feb 10 2007
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=945






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 ;-)


-- 
Aug 20 2007
prev sibling next sibling parent d-bugmail puremagic.com writes:
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



PDT ---



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: -------
Mar 27 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=945


Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugzilla digitalmars.com



11:45:01 PDT ---
changeset 478

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 10 2010
prev sibling parent d-bugmail puremagic.com writes:
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



Fixed DMD1.061 and DMD2.046.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 18 2010