Thread overview
[Bug 159] New: forward reverence with invalid struct
May 27, 2006
d-bugmail
[Bug 159] forward reference with invalid struct
Jun 01, 2006
d-bugmail
Jun 01, 2006
d-bugmail
Jun 02, 2006
Kyle Furlong
Jun 02, 2006
d-bugmail
May 27, 2006
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


-- 

June 01, 2006
http://d.puremagic.com/bugzilla/show_bug.cgi?id=159


bugzilla@digitalmars.com changed:

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




-- 

June 01, 2006
http://d.puremagic.com/bugzilla/show_bug.cgi?id=159





------- Comment #1 from bugzilla@digitalmars.com  2006-06-01 14:25 -------
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.


-- 

June 02, 2006
d-bugmail@puremagic.com wrote:
> http://d.puremagic.com/bugzilla/show_bug.cgi?id=159
> 
> 
> 
> 
> 
> ------- Comment #1 from bugzilla@digitalmars.com  2006-06-01 14:25 -------
> 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
June 02, 2006
http://d.puremagic.com/bugzilla/show_bug.cgi?id=159


smjg@iname.com changed:

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




------- Comment #2 from smjg@iname.com  2006-06-02 09:02 -------
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


--