Thread overview
[Issue 2458] New: Can't deduce sizeof inner struct inside a template mixin
Nov 16, 2008
d-bugmail
Jul 05, 2011
Jonas Drewsen
Dec 23, 2012
Andrej Mitrovic
Apr 06, 2013
Kenji Hara
November 16, 2008
http://d.puremagic.com/issues/show_bug.cgi?id=2458

           Summary: Can't deduce sizeof inner struct inside a template mixin
           Product: D
           Version: 2.020
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla@digitalmars.com
        ReportedBy: 2korden@gmail.com


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


-- 

July 05, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=2458


Jonas Drewsen <jdrewsen@gmail.com> changed:

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


--- Comment #1 from Jonas Drewsen <jdrewsen@gmail.com> 2011-07-05 00:47:13 PDT ---
Reduced test case a bit:

mixin template A() {
    void foo() {}
}

void bar() {
    static struct C {
        mixin A!();
    };
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
December 23, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=2458


Andrej Mitrovic <andrej.mitrovich@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |andrej.mitrovich@gmail.com


--- Comment #2 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2012-12-23 11:13:18 PST ---
(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).

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


Kenji Hara <k.hara.pg@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |DUPLICATE


--- Comment #3 from Kenji Hara <k.hara.pg@gmail.com> 2013-04-06 10:52:17 PDT ---
(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 ***

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------