www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 2067] New: call from anonymous class makes access violation.

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

           Summary: call from anonymous class makes access violation.
           Product: D
           Version: 1.029
          Platform: PC
        OS/Version: All
            Status: NEW
          Severity: regression
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: benoit tionex.de


module test;
extern(C) int printf(char*,...);
class I {
    abstract void callI();
}
class Base {
    int index;
}
class C : Base {
    void test1(){
        printf( "ok\n" );
    }
    void test(){
        auto i = new class() I {
            public void callI() {
                test1();
                if( index is -1 ){ // Access to the outer-super-field triggers
the bug
                    test1();
                }
            }
        };
        i.callI();
    }
}
void main () {
    auto c = new C;
    c.test();
}


-- 
May 04 2008
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2067






changing
   if( index is -1 ){
into
   if( this.outer.index is -1 ){
and the runtime error goes away.


-- 
May 04 2008
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2067






I can't reproduce that fix, Frank.  It still segfaults.

However, this bug only manifests with GDC.  It works fine with DMDWin.  See
http://d.puremagic.com/issues/show_bug.cgi?id=1669.  Should this bug be marked
as a duplicate?


-- 
May 04 2008
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2067






I can reproduce it with DMD 1.029 on windows+linux. I cannot say about GDC.
This is a regression, so i don't think it is related to GDC.

Test on Windows with DMD:
F:\dwt-samples>g:\dmd-1.029\dmd\bin\dmd test.d

F:\dwt-samples>test
Error: Access Violation

F:\dwt-samples>g:\dmd-1.028\dmd\bin\dmd test.d

F:\dwt-samples>test
ok


Test on linux ubuntu 8.04 with dmd:
frank lingurke:~/dwt/dwt-samples$ ~/dmd-1.029/dmd/bin/dmd test.d
frank lingurke:~/dwt/dwt-samples$ ./test
Segmentation fault
frank lingurke:~/dwt/dwt-samples$ ~/dmd-1.028/dmd/bin/dmd test.d
frank lingurke:~/dwt/dwt-samples$ ./test
ok


-- 
May 05 2008
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2067






Now DMD 1.030 is out and this minimal example works, but real program with this
scenario still crash.

I found a modification of the original test case that crashes on 1.030 but not
on 1.029 and 1.028.

module test;
extern(C) int printf(char*,...);

class I {
    public abstract void callI();
}

class C  {
    private int index;
    void test1(){
        printf( "ok\n" );
    }
    I test(){
        auto i = new class() I {
            public void callI() {
                test1();
            }
        };
        return i;
    }
}
void main () {
    auto c = new C;
    auto i = c.test();
    i.callI();
}


-- 
May 17 2008
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2067


bugzilla digitalmars.com changed:

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





Fixed dmd 1.030 and 2.014


-- 
May 22 2008
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2067







 Fixed dmd 1.030 and 2.014
 
--
May 23 2008