Thread overview
[Issue 8951] New: static array of context pointer struct s fails:
Nov 03, 2012
Maxim Fomin
Nov 08, 2012
Denis Shelomovskij
November 03, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8951

           Summary: static array of context pointer struct s fails:
           Product: D
           Version: unspecified
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: monarchdodra@gmail.com


--- Comment #0 from monarchdodra@gmail.com 2012-11-03 02:47:13 PDT ---
Creating a static array of structs that have a context pointer is not supported:

//----
import std.stdio;

void main()
{
    int a;

    struct S
    {
        ~this()
        {
            writeln("pre ++a");
            ++a;
            writeln("post ++a");
        }
    }

    {
        writeln(1);
        S stuff;
        writeln(2);
    }
    writeln(3);

    {
        writeln(4);
        S[2] stuff;
        writeln(5);
    }
    writeln(6);
}
//----
1
2
pre ++a
post ++a
3

4
5
pre ++a
object.Error: Access Violation
//----

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



--- Comment #1 from monarchdodra@gmail.com 2012-11-03 03:02:18 PDT ---
(In reply to comment #0)
> Creating a static array of structs that have a context pointer is not supported:

Simpler example:

import std.stdio;

//----
void main()
{
    int a;

    struct S
    {
        void doit()
        {
            writeln("pre ++a");
            ++a;
            writeln("post ++a");
        }
    }

    {
        S s;
        s.doit;
    }

    {
        S[2] ss;
        ss[0].doit;
    }
}
//----
pre ++a
post ++a
pre ++a
object.Error: Access Violation
//----

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


Maxim Fomin <maxim@maxim-fomin.ru> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |maxim@maxim-fomin.ru


--- Comment #2 from Maxim Fomin <maxim@maxim-fomin.ru> 2012-11-03 06:42:44 PDT ---
Seems to be issue 8923

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


Denis Shelomovskij <verylonglogin.reg@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |verylonglogin.reg@gmail.com
         Resolution|                            |DUPLICATE


--- Comment #3 from Denis Shelomovskij <verylonglogin.reg@gmail.com> 2012-11-08 18:32:53 MSK ---
*** This issue has been marked as a duplicate of issue 8923 ***

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