www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 5365] New: Regression (2.051) alias this causes segfault

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5365

           Summary: Regression (2.051) alias this causes segfault
           Product: D
           Version: D2
          Platform: Other
        OS/Version: Linux
            Status: NEW
          Severity: regression
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: samukha voliacable.com



PST ---
The following compiles and runs correctly with dmd 2.050, but segfaults with
dmd 2.051

interface IFactory
{
    void foo();
}

class A
{
    protected static class Factory : IFactory
    {
        void foo()
        {
        }           
    }

    this()
    {
        _factory = createFactory();
    }

    protected IFactory createFactory()
    {
        return new Factory;
    }

    private IFactory _factory;
     property final IFactory factory()
    {
        return _factory;
    }

    alias factory this;            
}  

void main()
{

    IFactory f = new A;
    f.foo(); // segfault
}

Critical for QtD.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Dec 23 2010
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5365


bearophile_hugs eml.cc changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bearophile_hugs eml.cc



It works with DMD 2.051 if I replace this line of the main():
IFactory f = new A;

With:
A f = new A;

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Dec 23 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5365




PST ---

 It works with DMD 2.051 if I replace this line of the main():
 IFactory f = new A;
 
 With:
 A f = new A;
We still need the implicit cast to work correctly. For example, we cannot pass an A to a function taking an IFactory: void bar(IFactory f) { f.foo(); // segfault } auto a = new A; bar(a); Here is a simplified test-case: class B { } class A { B _b; this() { _b = new B; } B b() { return _b; } alias b this; } void main() { auto a = new A; B b = a; // b is null assert(a._b is b); // fails } -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Dec 23 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5365




PST ---
Changed subject to something arguably more relevant.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Dec 23 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5365


Walter Bright <bugzilla digitalmars.com> changed:

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



18:32:51 PST ---
This was broken by the fix for 5094. The fix for 5094 was good, it just exposed
another problem that needed fixing.

http://www.dsource.org/projects/dmd/changeset/818

QtD is an important project for D; please consider trying out the beta
compilers as they come out to head off regresssions in the future.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Dec 26 2010
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5365




PST ---

 This was broken by the fix for 5094. The fix for 5094 was good, it just exposed
 another problem that needed fixing.
 
 http://www.dsource.org/projects/dmd/changeset/818
This fixes the issue. Thanks! There is yet another issue that prevents us from implementing multiple inheritance in a satisfactory way http://d.puremagic.com/issues/show_bug.cgi?id=5380
 
 QtD is an important project for D; please consider trying out the beta
 compilers as they come out to head off regresssions in the future.
We usually do but not this particular version. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Dec 27 2010