a bug invoking base class's property?

H

Huihong

I found when invoking the same property of a base class,
the MC++ compiler seems to emit incorrect IL code, and
causes causes stack overflow:

class Child : public Parent {
__property void set_Text(String *s)
{
Parent::Text = s;
}
};

It emits:
call instance void Child::set_Text(string)

is it supposed to be?
call instance void Parent::set_Text(string)

Is this a bug, or desired behavior?

Thanks,

Huihong
Remotesoft

======= test code ========
#include <windows.h>
#using <mscorlib.dll>

using namespace System;

__gc class Parent
{

public:
virtual void Test(void)
{
}

__property void set_Text(String* msg)
{
}
};

__gc class Child : public Parent
{
public:
virtual void Test(void)
{
Parent::Test();
}

__property void set_Text(String* msg)
{
// this causes stack overflow, IL: call
instance void Child::set_Text(string)
Parent::Text = msg;

// this is fine, IL: call instance void
Parent::set_Text(string)
Parent::set_Text(msg);
}
};

int main()
{
Child* c = new Child();
c->Test(); // this is fine
c->Text = S"Huihong";
return 0;
}
 
G

Guest

Huihong,

What version / build of the compiler are you using? Your code compiles and runs correctly for me on whidbey 31216.00

--
Jackson Davis [MSFT]

This posting is provided "AS IS" with no warranties, and confers no rights. Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm

Note: For the benefit of the community-at-large, all responses to this message are best directed to the newsgroup/thread from which they originated.
--------------------
 
H

Huihong

Hi Jackson,

Thanks for the help. I was using v1.1.4322, will try
whidbey PDC 2003 release. If Whidbey works, then the bug
has been fixed.

Huihong
-----Original Message-----
Huihong,

What version / build of the compiler are you using? Your
code compiles and runs correctly for me on whidbey 31216.00confers no rights. Use of included script samples are
subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm

Note: For the benefit of the community-at-large, all
responses to this message are best directed to the
newsgroup/thread from which they originated.
 
H

Huihong

I tried Whidbey PDC2003 release, it didn't work, see
below. Running the compiled exe causes stack overflow. The
compiler issued a warning, which is why I wonder whether
this is a desired behavior.

Perhaps, the bug was fixed after pdc release.

C:\experimental>cl /clr SuperCallTest.cpp
Microsoft (R) C/C++ Optimizing Compiler Version
14.00.30703.27
for Microsoft (R) .NET Framework version 1.02.30703.27
Copyright (C) Microsoft Corporation. All rights reserved.

SuperCallTest.cpp
c:\experimental\supercalltest.cpp(34) : warning
C4717: 'Child::set_Text' : recur
sive on all control paths, function will cause runtime
stack overflow
Microsoft (R) Incremental Linker Version 8.00.30703.27
Copyright (C) Microsoft Corporation. All rights reserved.

/out:SuperCallTest.exe
SuperCallTest.obj

-----Original Message-----
Huihong,

What version / build of the compiler are you using? Your
code compiles and runs correctly for me on whidbey 31216.00confers no rights. Use of included script samples are
subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm

Note: For the benefit of the community-at-large, all
responses to this message are best directed to the
newsgroup/thread from which they originated.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top