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





------- Comment #1 from benoit tionex.de  2008-05-04 16:33 -------
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





------- Comment #2 from jarrett.billingsley gmail.com  2008-05-04 21:41 -------
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





------- Comment #3 from benoit tionex.de  2008-05-05 18:12 -------
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





------- Comment #4 from benoit tionex.de  2008-05-17 18:10 -------
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




------- Comment #5 from bugzilla digitalmars.com  2008-05-22 05:03 -------
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





------- Comment #6 from benoit tionex.de  2008-05-23 12:48 -------
(In reply to comment #5)
 Fixed dmd 1.030 and 2.014
 

Hm, so i have put the new test case into a new bug report. See #2123 --
May 23 2008