www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Bug 159] New: forward reverence with invalid struct

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/bugzilla/show_bug.cgi?id=159

           Summary: forward reverence with invalid struct
           Product: D
           Version: 0.159
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: benoit tionex.de


This compiled with dmd 0.157. Well i think its not legal code ...

public struct S; // this should be an error, i think
public struct S1 { // error is show here
    S s;
}

Error:
mod.d(7): struct mod.S1 unable to resolve forward reference


-- 
May 27 2006
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/bugzilla/show_bug.cgi?id=159


bugzilla digitalmars.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |INVALID




-- 
Jun 01 2006
prev sibling next sibling parent reply d-bugmail puremagic.com writes:
http://d.puremagic.com/bugzilla/show_bug.cgi?id=159






It's ok to declare a struct without { }. However, this won't work if the size
of S is needed, as it is in S1. Hence, the error diagnostic.


-- 
Jun 01 2006
parent Kyle Furlong <kylefurlong gmail.com> writes:
d-bugmail puremagic.com wrote:
 http://d.puremagic.com/bugzilla/show_bug.cgi?id=159
 
 
 
 
 

 It's ok to declare a struct without { }. However, this won't work if the size
 of S is needed, as it is in S1. Hence, the error diagnostic.
 
 
Maybe a more helpful diagnostic then? -- Kyle Furlong // Physics Undergrad, UCSB "D is going wherever the D community wants it to go." - Walter Bright
Jun 01 2006
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/bugzilla/show_bug.cgi?id=159


smjg iname.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|INVALID                     |





Since when has "forward reference" meant this?  In my vocabulary, a forward
reference is when you refer to something before it's declared.  Which isn't
happening here.  A forward _declaration_, OTOH, is when you declare something
and then define it later.  This would be a forward declaration except that in
this example, S is never defined.

As such, what we have isn't a forward anything.  So of course it's a badly
written error message.

A better error would be:

mod.d(7): unable to resolve declaration of type S - size is unknown


-- 
Jun 02 2006