August 30, 2013
On Sat, Aug 31, 2013 at 03:27:58AM +1000, Manu wrote:
> struct MyStruct; // <- forward declared (opaque type, never defined)
> 
> MyStruct*[] arrayOfPointers;
> 
> arrayOfPointers ~= null; // appending doesn't work
> arrayOfPointers = new MyStruct*[n]; // or just allocating the array doesn't
> work either
> 
> Complains:
> 1>code.d(84): Error: struct MyStruct is forward referenced when looking for
> 'toHash'
> 1>code.d(84): Error: struct MyStruct is forward referenced when looking for
> 'opCmp'
> 1>code.d(84): Error: struct MyStruct is forward referenced when looking for
> 'toString'
> 1>code.d(84): Error: struct MyStruct unknown size
> 1>code.d(84): Error: struct MyStruct no size yet for forward reference
> 1>code.d(84): Error: struct MyStruct unknown size
> 1>code.d(84): Error: struct MyStruct no size yet for forward reference
> 
> What's the go here?
> Why would it need any of that information? It's just a pointer...

Just a guess, but it looks like it might be caused by the compiler trying to generate the typeinfo for MyStruct. Probably fixable, since only the pointer is used here, so generating the typeinfo isn't strictly necessary. (But I don't know enough about dmd internals to be able to say for sure...)


T

-- 
Mediocrity has been pushed to extremes.