[Issue 8603] New: Member access operator doesn't always dereference the pointer it's operating on
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri Aug 31 01:48:39 PDT 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8603
Summary: Member access operator doesn't always dereference the
pointer it's operating on
Product: D
Version: D2
Platform: All
OS/Version: All
Status: NEW
Severity: normal
Priority: P2
Component: DMD
AssignedTo: nobody at puremagic.com
ReportedBy: tommitissari at hotmail.com
--- Comment #0 from Tommi <tommitissari at hotmail.com> 2012-08-31 01:48:32 PDT ---
struct S1
{
int _value = 42;
void fun()
{
++_value;
}
}
void fun(ref S1 s1)
{
s1._value += 1000;
}
void fun(ref S1* ptr1)
{
++ptr1;
}
/////////////////////////////
struct S2
{
int _value = 42;
}
void fun(ref S2 s2)
{
++s2._value;
}
void fun(ref S2* ptr2)
{
++ptr2;
}
/////////////////////////////
struct S3
{
int _value = 42;
}
void fun(ref S3 s3)
{
++s3._value;
}
void main()
{
auto ptr1 = new S1();
ptr1.fun(); // OK: calls member (*ptr1).fun()
auto ptr2 = new S2();
ptr2.fun(); // WRONG: calls .fun(ptr2)
// should call .fun(*ptr2)
auto ptr3 = new S3();
ptr3.fun(); // ERROR: function main.fun (ref S3 s3) is
// not callable using argument types (S3*)
// Should call .fun(*ptr3)
}
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list