no size yet for forward reference error

Jonathan M Davis via Digitalmars-d digitalmars-d at puremagic.com
Thu Feb 25 12:47:51 PST 2016


On Thursday, 25 February 2016 at 20:14:20 UTC, Marc Schütz wrote:
> On Thursday, 25 February 2016 at 17:33:34 UTC, Jonathan M Davis 
> wrote:
>> Actually, both of your examples compile for me - both with 
>> master and with 2.070.0. I'm running on x86_64 FreeBSD (which 
>> you probably aren't), which shouldn't matter for this sort of 
>> error, but I suppose that it's possible that it's somehow 
>> system-specific, much as I wouldn't expect it to be. So, I 
>> don't what to say. :|
>
> You need to compile with `-unittest`.

Ah, yes. I see now. And yes, that fails to compile.

Well, given that you have types referring to each other, it's not 
all that hard to get a circular definition error. The most 
obvious is when you do something like

     struct A
     {
         B b;
     }

     struct B
     {
         A a;
     }

And while the code in question doesn't do anything that blatant, 
it is having types refer to each other. What's incredibly weird 
is that if the RefCounted!(Payload, RefCountedAutoInitialize.no) 
is changed to Payload, the code works. If there were going to be 
a circular definition problem, then I'd think that it would occur 
without RefCounted being involved.

I'd suggest copying RefCounted to your local file and using that 
version of it rather than introducing std.typecons into the mix, 
and then use dustmite to reduce it. Then you can track down which 
part of RefCounted is causing the problem. dustmite is now 
released with dmd, I believe, so you shouldn't need to track it 
down, and instructions for it can be found here:

https://github.com/CyberShadow/DustMite/wiki

- Jonathan M Davis


More information about the Digitalmars-d mailing list