[Issue 24793] New: Allow implicit conversion of const pointers to void*
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri Oct 4 12:43:46 UTC 2024
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 at puremagic.com
Reporter: dkorpel at 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`?
--
More information about the Digitalmars-d-bugs
mailing list