Bug 2458 – Can't deduce sizeof inner struct inside a template mixin

Status
RESOLVED
Resolution
DUPLICATE
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2008-11-16T07:51:00Z
Last change time
2015-06-09T01:20:26Z
Keywords
rejects-valid
Assigned to
nobody
Creator
2korden

Comments

Comment #0 by 2korden — 2008-11-16T07:51:29Z
The following code triggers an error: template Foo() { uint getSize() { return (*this).sizeof; // line 5 } } void main() { struct A1 { mixin Foo!(); // line 13 } } test.d(5): struct test.main.A1 no size yet for forward reference test.d(13): mixin test.main.A1.Foo!() error instantiating
Comment #1 by jdrewsen — 2011-07-05T00:47:13Z
Reduced test case a bit: mixin template A() { void foo() {} } void bar() { static struct C { mixin A!(); }; }
Comment #2 by andrej.mitrovich — 2012-12-23T11:13:18Z
(In reply to comment #1) > Reduced test case a bit: > > mixin template A() { > void foo() {} > } > > void bar() { > static struct C { > mixin A!(); > }; > } That works in 2.061, however OP code still doesn't work. Also it should probably use 'typeof(this).sizeof', not '(*this).sizeof' (which gives a separate error).
Comment #3 by k.hara.pg — 2013-04-06T10:52:17Z
(In reply to comment #2) > That works in 2.061, however OP code still doesn't work. OP code is a dup of bug 9417. *** This issue has been marked as a duplicate of issue 9417 ***