Jump to page: 1 2
Thread overview
[Issue 10451] New: Array of pointers to opaque struct gives forward reference errors.
Jun 23, 2013
Mike Parker
Aug 11, 2013
Mike Parker
Sep 01, 2013
Manu
Sep 01, 2013
Ali Cehreli
Sep 01, 2013
Manu
Sep 18, 2013
Iain Buclaw
Sep 18, 2013
Manu
Sep 18, 2013
Iain Buclaw
Sep 18, 2013
Manu
Sep 29, 2013
Kenji Hara
Sep 29, 2013
Kenji Hara
Sep 29, 2013
Andrej Mitrovic
Oct 02, 2013
Kenji Hara
June 23, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10451

           Summary: Array of pointers to opaque struct gives forward
                    reference errors.
           Product: D
           Version: D2
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Severity: major
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: aldacron@gmail.com


--- Comment #0 from Mike Parker <aldacron@gmail.com> 2013-06-23 08:42:23 PDT ---
struct foo;

struct bar {
    foo*[] foos;
}

The error only occurs when the array is declared as a struct field. When declared as a class member or in a function, there is no error.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
August 11, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10451



--- Comment #1 from Mike Parker <aldacron@gmail.com> 2013-08-11 07:23:09 PDT ---
I've got some new info on this. The error also occurs outside of structs if the array is initialized:

=========
struct foo;

void main() {
    foo*[] foos = [];
}
=========

Here's the full error spew that I get in both cases:

==================
forref.d(3): Error: struct forrref.foo is forward referenced when looking for
't
oHash'
forref.d(3): Error: struct forrref.foo is forward referenced when looking for
'o
pCmp'
forref.d(3): Error: struct forrref.foo is forward referenced when looking for
't
oString'
forref.d(3): Error: struct forrref.foo unknown size
forref.d(3): Error: struct forrref.foo no size yet for forward reference
forref.d(3): Error: struct forrref.foo unknown size
forref.d(3): Error: struct forrref.foo no size yet for forward reference
===================

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
September 01, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10451


Manu <turkeyman@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |turkeyman@gmail.com


--- Comment #2 from Manu <turkeyman@gmail.com> 2013-08-31 17:45:25 PDT ---
http://d.puremagic.com/issues/show_bug.cgi?id=10451

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
September 01, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10451


Ali Cehreli <acehreli@yahoo.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |acehreli@yahoo.com


--- Comment #3 from Ali Cehreli <acehreli@yahoo.com> 2013-08-31 20:05:39 PDT ---
Manu meant this: :)

  http://d.puremagic.com/issues/show_bug.cgi?id=10766

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
September 01, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10451



--- Comment #4 from Manu <turkeyman@gmail.com> 2013-08-31 23:00:46 PDT ---
(In reply to comment #3)
> Manu meant this: :)
> 
>   http://d.puremagic.com/issues/show_bug.cgi?id=10766

Haha, thx ;)

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
September 18, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10451


Iain Buclaw <ibuclaw@ubuntu.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ibuclaw@ubuntu.com


--- Comment #5 from Iain Buclaw <ibuclaw@ubuntu.com> 2013-09-18 04:18:33 PDT ---
This happens because, eg: array literals are initialised by the GC by calling _d_arrayliteralTX (typeinfo, dim);

This requires that the struct has a complete runtime type information about a type.  Something that does not get generated for opaque types, which makes this bug not the easiest to fix - and the same is with other array operations which also require typeinfo to be available.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
September 18, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10451



--- Comment #6 from Manu <turkeyman@gmail.com> 2013-09-18 04:39:28 PDT ---
But the compiler doesn't need to know anything about the type to allocate an array of pointers. Surely the compiler can use/share the typeinfo of void* in this case?

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
September 18, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10451



--- Comment #7 from Iain Buclaw <ibuclaw@ubuntu.com> 2013-09-18 05:41:37 PDT ---
(In reply to comment #6)
> But the compiler doesn't need to know anything about the type to allocate an array of pointers. Surely the compiler can use/share the typeinfo of void* in this case?

Sure we could use void* if is your expectation for typeid(foo*).toString to
return "void*"  =)

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
September 18, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10451



--- Comment #8 from Manu <turkeyman@gmail.com> 2013-09-18 05:46:42 PDT ---
Surely it can't be hard to synthesize a named pointer type... unless it's dereferenced, it shouldn't need an actual definition in the typeinfo. So it would just be a stub or dummy typeinfo that's empty?

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
September 18, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10451


grogan.colin@gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |grogan.colin@gmail.com


--- Comment #9 from grogan.colin@gmail.com 2013-09-18 05:48:42 PDT ---
A possible workaround to this is to create the struct like:

struct foo {}

Though, in this case it isn't an opaque struct and is merely a struct with no members.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
« First   ‹ Prev
1 2