void f(int*[] a, const int*[] b)
{
void[] a1=a;
const void[] b1=b;
a1[]=b1[];
*a[0]=0; //modify const data
}
Probably void[] shouldn't be writable without an explicit cast to, say, byte[].
Pretty similar to issue 2095: cast to void[] here is an upcast and should add const qualifier. If the data was allocated as void[] from the beginning, then it may be writable.
Comment #1 by dkorpel — 2022-03-24T11:54:40Z
If you mark `f` `@safe` it results in an error:
Error: cannot copy `void[]` to `void[]` in `@safe` code
Comment #2 by dlang-bot — 2024-06-14T11:40:36Z
@ntrel created dlang/dmd pull request #16583 "Fix Bugzilla 17148 - Copying from const(void)[] to void[] breaks immu…" fixing this issue:
- Fix Bugzilla 17148 - Copying from const(void)[] to void[] breaks immutable
https://github.com/dlang/dmd/pull/16583
Comment #3 by nick — 2024-06-14T11:44:02Z
> Probably void[] shouldn't be writable
Assuming only slice assignment can write to it, I think we can just disallow copying from const(void)[]. That's what the pull does.
Comment #4 by dlang-bot — 2024-06-17T09:11:58Z
dlang/dmd pull request #16583 "Fix Bugzilla 17148 - Copying from const(void)[] to void[] breaks immu…" was merged into master:
- e93d798c2bccffed4c66bd797e10e32cdab22d82 by Nick Treleaven:
Fix Bugzilla 17148 - Copying from const(void)[] to void[] breaks immutable
https://github.com/dlang/dmd/pull/16583