Bug 10793 – Forward reference errors casting from void* to opaque struct pointer
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-08-11T07:31:00Z
Last change time
2013-08-18T04:11:37Z
Keywords
pull, rejects-valid
Assigned to
nobody
Creator
aldacron
Comments
Comment #0 by aldacron — 2013-08-11T07:31:53Z
module forrref;
struct RealFoo {
int i;
}
struct foo;
void main() {
auto rf = RealFoo( 10 );
void* prf = cast( void* )rf;
foo* f = cast( foo* )prf;
}
forref.d(7): Error: struct forrref.foo unknown size
forref.d(7): Error: struct forrref.foo no size yet for forward reference
forref.d(7): Error: struct forrref.foo unknown size
forref.d(7): Error: struct forrref.foo no size yet for forward reference
Comment #1 by andrej.mitrovich — 2013-08-11T08:27:30Z
Similar or dupe of Issue 10497.
Comment #2 by henning — 2013-08-11T11:21:17Z
I cannot reproduce either this or 10497 using git head.
Comment #3 by andrej.mitrovich — 2013-08-11T11:35:34Z
(In reply to comment #2)
> I cannot reproduce either this or 10497 using git head.
I can reproduce this test-case in git-head (b55f805133f9d249890ddf6b98270ca826b3e26b) but with only one error now:
test.d(11): Error: e2ir: cannot cast rf of type RealFoo to type void*
I can fully reproduce both issues with 2.063.
However I can no longer reproduce Issue 10497 in git-head. I suggest we add a test-case for 10497 before that bug is reintroduced. As for this Issue 10793, could you test it with git-head again?
Comment #4 by henning — 2013-08-11T15:45:56Z
He just missed a 'new' before RealFoo, I guess.
Comment #5 by andrej.mitrovich — 2013-08-11T22:57:49Z
(In reply to comment #4)
> He just missed a 'new' before RealFoo, I guess.
Ah my bad, yes. Do you want to add these test-cases or should I? Let's not let them creep in again. :)
Comment #6 by aldacron — 2013-08-12T00:42:08Z
(In reply to comment #4)
> He just missed a 'new' before RealFoo, I guess.
Actually, I missed an '&'!
void* prf = cast( void* )rf;
But new works, too!
Given that this works with git head, I wonder about bug 10451.