[Bug 248] New: Regression: Call result not properly saved when calling a vtbl function
via D.gnu
d.gnu at puremagic.com
Sat Dec 10 02:46:22 PST 2016
http://bugzilla.gdcproject.org/show_bug.cgi?id=248
Bug ID: 248
Summary: Regression: Call result not properly saved when
calling a vtbl function
Product: GDC
Version: development
Hardware: All
OS: All
Status: NEW
Severity: normal
Priority: Normal
Component: gdc
Assignee: ibuclaw at gdcproject.org
Reporter: johannespfau at gmail.com
Reduced from a DDMD build regression:
We've got a function getMemtype which has side effects and returns a class
object Bar which has a virtual function isintegral. The function is called in
this way: getMemtype().isintegral(). In this call the return value of
getMemtype, the reference to a Bar object, is needed twice: Once to get the
vtbl entry for isintegral and once to pass the object reference as the this
pointer for isintegral. I guess the result of the getMemtype call is not saved
properly. We can certainly see that the getMemType function executes twice.
@Iain I'll assign this to you as you are more familiar with this code.
---------------------------------------------------
import std.stdio;
class Bar
{
bool isintegral()
{
return false;
}
}
class Symbol
{
Bar getMemtype()
{
writeln("foo");
return new Bar();
}
}
class Enum
{
Symbol sym;
bool isintegral()
{
return sym.getMemtype().isintegral();
}
}
void main()
{
Enum e = new Enum();
e.sym = new Symbol();
e.isintegral();
}
---------------------------------------------------
--
You are receiving this mail because:
You are watching all bug changes.
More information about the D.gnu
mailing list