[Mono-list] [Fwd: Sample Test]

Joe Tennies rotund@fatnsoft.com
08 Feb 2002 21:39:00 -0600


grrr... wrong account again... trying to keep spam and lots of mailing
lists outta my main account... as of now, it's a pain in the butt =)

-----Forwarded Message-----

> To: Joe Tennies <rotund@fatnsoft.com>
> Cc: mono-list@ximian.com
> Subject: RE: [Mono-list] [Fwd: Sample Test]
> Date: 08 Feb 2002 21:36:25 -0600
> 
> Whoops... this is an infinite loop... GRRRRR... wish I could remember
> exactly how it worked... here's the basics of it:
> 
> the class would call the global version of a function instead of one
> from its parent.  The key was that you had to inherit several levels
> deep before you noticed it.
> 
> On Fri, 2002-02-08 at 21:07, Joe Tennies wrote:
> > Darn it.  That means I must have screwed up the test (I was writing it
> > from memory).
> > 
> > That was the basic problem.  It wouldn't look to the correct place.  The
> > test should fail on all the compilers you mentioned and then some (Code
> > Warrior's and Borland's, though I think Borland has since fixed it.)
> > 
> > The test appeared in Windows Developer's Journal (or something like
> > that)... it was a "Bug of the month" or "Bug++ of the Month"  If someone
> > could look it up for me (I read this at my old job... like the August
> > 2001 issue... somewhere between summer and December of 2001)
> > 
> > Perhaps the test was actually:
> > 
> > > int Bar()
> > > {
> > >    return 0;
> > > }
> > > 
> > > class cParent
> > > {
> > >    public:
> > >       int Bar() {return 1;}
> > > }
> > > 
> > > class cChild : public cParent
> > > {
> > > }
> > > 
> > > class cGrandchild : public cChild
> > > {
> > >    int Bar() { return Bar(); }
> > > }
> > > 
> > > int main()
> > > {
> > >    cGrandhild* gcInstance = new cGrandchild();
> > >    
> > >    if (gcInstance->Foo() == gcInstance->Bar())
> > >       return 0;
> > >    else
> > >    {
> > >       cout << "Problem w/ inheritance and global functions."
> > >       return 1;
> > >    }
> > > }
> > 
> > --------------------------------------------------
> > Message: 4
> > Subject: RE: [Mono-list] [Fwd: Sample Test]
> > charset="us-ascii"
> > Date: Fri, 8 Feb 2002 03:56:31 -0800
> > From: "Piers Haken" <piersh@friskit.com>
> > To: <mono-list@ximian.com>
> > 
> > Joe, there's no such thing as a global function in c#. Just like in
> > Java, every method must be a member of a class. I guess a public static
> > method could be considered 'global'. I'm sure this would be a good
> > addition to the Mono compiler test suites.
> > 
> > On the other hand, I'm not sure which C++ compilers you were trying. It
> > works fine for me on VC6, VC7, g++/cygwin, g++/debian.
> > 
> > Piers.
> > 
> > -----Original Message-----
> > From: Joe Tennies [mailto:rotund@fatnsoft.com] 
> > Sent: Thursday, February 07, 2002 7:37 PM
> > To: mono-list@ximian.com
> > Subject: [Mono-list] [Fwd: Sample Test]
> > 
> > 
> > Oops.  Tried to send this w/ the wrong account.  Try this again
> > 
> > > I am still learning C#, so I'll submit this test in C++.  I know this 
> > > used to fail on almost every C++ compiler (really don't know why).
> > > 
> > > int Bar()
> > > {
> > >    return 0;
> > > }
> > > 
> > > class cParent
> > > {
> > >    public:
> > >       int Bar() {return 1;}
> > > }
> > > 
> > > class cChild : public cParent
> > > {
> > > }
> > > 
> > > class cGrandchild : public cChild
> > > {
> > >    int Foo() {return Bar();}
> > > }
> > > 
> > > int main()
> > > {
> > >    cGrandhild* gcInstance = new cGrandchild();
> > >    
> > >    if (gcInstance->Foo() == gcInstance->Bar())
> > >       return 0;
> > >    else
> > >    {
> > >       cout << "Problem w/ inheritance and global functions."
> > >       return 1;
> > >    }
> > > }
> > > 
> > > Most C++ compilers would return gcInstance->Foo() == 0.  This means it
> > 
> > > would call the global instance.
> > > 
> > > I don't know if you can create a global function in C#.  If you can, 
> > > this would be a good test to run.
> > > 
> > 
> > 
> > 
> > 
> > _______________________________________________
> > Mono-list maillist  -  Mono-list@ximian.com
> > http://lists.ximian.com/mailman/listinfo/mono-list
> > 
>