Thread overview
[Issue 11265] New: Segfault while calling instance method of class defined inside struct
Oct 15, 2013
Kenji Hara
Oct 15, 2013
Walter Bright
October 15, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=11265

           Summary: Segfault while calling instance method of class
                    defined inside struct
           Product: D
           Version: D2
          Platform: x86_64
        OS/Version: Linux
            Status: NEW
          Severity: regression
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: jcrapuchettes@gmail.com


--- Comment #0 from Jonathan Crapuchettes <jcrapuchettes@gmail.com> 2013-10-14 17:22:51 PDT ---
Running with D 2.063.2 the following code compiles and runs without any problems. Using git checkout 4a2fabf, the code compiles, but segfaults when trav.empty() is called. Possible changes to the code that will allow it to run correctly are noted in the comments.

struct S
{
    //works if the class is moved out of the struct
    class InnerClass //works if final is added
    {
        S s;    //works if removed

        bool empty()
        {
            return true;
        }
    }
}

void main()
{
    S.InnerClass trav = new S.InnerClass();
    trav.empty();
}

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


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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull, wrong-code


--- Comment #1 from Kenji Hara <k.hara.pg@gmail.com> 2013-10-15 07:45:16 PDT ---
https://github.com/D-Programming-Language/dmd/pull/2670

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



--- Comment #2 from github-bugzilla@puremagic.com 2013-10-15 12:31:56 PDT ---
Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/0d930c9e9e0ad45dbcd5d876ff9ef66ae5d1c4b7
fix Issue 11265 - Segfault while calling instance method of class defined
inside struct

The regression was introduced by the commit: https://github.com/D-Programming-Language/dmd/commit/671b7c20b96b580ee1dc2b3f5e3ee66c63d079b6#diff-43282ebf5a2de5fdbcb3b5083ddf949dR147

vtbl[] calculation is essentially unrelated to the class instance size. So, just only once initializing of vtbl[] and running semantic on member functions is sufficient.

https://github.com/D-Programming-Language/dmd/commit/a95bbf4642e349fffea5a567157a4599ceb96ab9 Merge pull request #2670 from 9rnsr/fix11265

[REG2.064a] Issue 11265 - Segfault while calling instance method of class defined inside struct

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



--- Comment #3 from github-bugzilla@puremagic.com 2013-10-15 12:34:45 PDT ---
Commit pushed to 2.064 at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/d1d46c7c31ec497ff7f09e178cf357ba7369aad4 Merge pull request #2670 from 9rnsr/fix11265

[REG2.064a] Issue 11265 - Segfault while calling instance method of class defined inside struct

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


Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bugzilla@digitalmars.com
         Resolution|                            |FIXED


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