[Issue 8545] New: defined opCast disables cast(void*)this in classes
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sun Aug 12 20:33:48 PDT 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8545
Summary: defined opCast disables cast(void*)this in classes
Product: D
Version: D2
Platform: All
OS/Version: All
Status: NEW
Severity: major
Priority: P2
Component: DMD
AssignedTo: nobody at puremagic.com
ReportedBy: andrej.mitrovich at gmail.com
--- Comment #0 from Andrej Mitrovic <andrej.mitrovich at gmail.com> 2012-08-12 20:33:46 PDT ---
class Foo
{
T opCast(T : int)() { return 1; }
void* test() { return cast(void*)this; }
}
void main() { }
This is problematic, cast(void*)this is the trick used to get the address of
'this' object. &this is the address of the reference and can't be used for the
same purpose. So defining opCast for any type ends up disabling
'cast(void*)this'.
I honestly think we should have a druntime function or some kind of compiler
intrinsic to get the equivalent of 'cast(void*)this'. That cast itself looks
too hacky to begin with.
--
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