D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 9735 - Casting delegates to void* should be illegal
Summary: Casting delegates to void* should be illegal
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P2 minor
Assignee: No Owner
URL:
Keywords: accepts-invalid
Depends on:
Blocks:
 
Reported: 2013-03-16 03:30 UTC by David Nadlinger
Modified: 2013-03-16 06:32 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description David Nadlinger 2013-03-16 03:30:03 UTC
As per http://forum.dlang.org/post/kibnaskimiqnmzziegjo@forum.dlang.org, the following snippet should not compile:

---
void* delegateToPtr(void delegate() dg) {
    return cast(void*)dg;
}
---

DMD currently returns the delegate context pointer.

As I couldn't find any justification for this in the spec, I marked the issue as an »accepts-invalid« bug, but feel free to downgrade it to an enhancement request.
Comment 1 Iain Buclaw 2013-03-16 04:44:39 UTC
Raised pull: https://github.com/D-Programming-Language/dmd/pull/1754