Thread overview
[Issue 1359] New: Can call non implemented functions
Jul 20, 2007
d-bugmail
Aug 11, 2007
d-bugmail
Sep 18, 2009
Rainer Schuetze
Sep 18, 2009
Don
July 20, 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1359

           Summary: Can call non implemented functions
           Product: D
           Version: 1.018
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla@digitalmars.com
        ReportedBy: moritzwarning@web.de


In this following example we can call Foo.get
even it is not implemented.
The program compiles and runs without problems, but shouldn't.
When Foo.get is implemented it also never get called.

The compiler recognizes the bug when the return type
for get isn't a template or interfaces Node and Nodes
changes places.


module Main;

class Bar(T)
{
}

//program compiles but crashes when interface is empty
interface Node : Nodes
{
        void print();
}

interface Nodes
{
        public:

        Bar!(Node) get();
}

class Foo : Node
{

public:

        void print() {  }
        /*
        //never get called when implemented
        Bar!(Node) get()
        {
                return null;
        }
        */
}

void main(char[][] args)
{
        Node foo = new Foo;

        foo.get();
}


-- 

August 11, 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1359





------- Comment #1 from moritzwarning@web.de  2007-08-11 08:45 -------
Created an attachment (id=169)
 --> (http://d.puremagic.com/issues/attachment.cgi?id=169&action=view)
alternative testcase

This is another testcase that show that applications can silently change behavior ,crash or just don't work only by switching the order of declaration of two interfaces. It doesn't matter if the interfaces are defined in another file.


-- 

September 18, 2009
http://d.puremagic.com/issues/show_bug.cgi?id=1359


Rainer Schuetze <r.sagitario@gmx.de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |r.sagitario@gmx.de


--- Comment #2 from Rainer Schuetze <r.sagitario@gmx.de> 2009-09-18 01:45:16 PDT ---
Seems to work fine with DMD 1.047 and DMD 2.032. I haven't tested the additional alternative testcase, though (because of the tango usage).

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
September 18, 2009
http://d.puremagic.com/issues/show_bug.cgi?id=1359


Don <clugdbug@yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |clugdbug@yahoo.com.au
         Resolution|                            |FIXED


--- Comment #3 from Don <clugdbug@yahoo.com.au> 2009-09-18 15:12:08 PDT ---
Fixed in 1.029 or 1.030.

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