October 04 [Issue 24793] New: Allow implicit conversion of const pointers to void* | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=24793 Issue ID: 24793 Summary: Allow implicit conversion of const pointers to void* Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: enhancement Priority: P3 Component: dmd Assignee: nobody@puremagic.com Reporter: dkorpel@live.nl When interfacing with C APIs, I sometimes find myself casting away const on void pointers. ``` void main() { const int* x = cast(int*) malloc(4); free(cast(void*) x); } struct Console { HANDLE handle; // HANDLE = void* on Windows void write(string s) const { WriteConsoleW(cast(void*) this.handle, ...); } } ``` This should be unnecessary. With void* you already completely give up on type safety, so why be persnickety about `const`? -- |
Copyright © 1999-2021 by the D Language Foundation