[Issue 24609] New: Array of struct with immutable field implicitly converts to void[]
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sat Jun 15 11:53:42 UTC 2024
https://issues.dlang.org/show_bug.cgi?id=24609
Issue ID: 24609
Summary: Array of struct with immutable field implicitly
converts to void[]
Product: D
Version: D2
Hardware: x86_64
OS: Linux
Status: NEW
Severity: normal
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: nick at geany.org
void main() @system
{
S[] a = [S(5)];
//a[0] = S(0); // error, modifying immutable member of S
void[] va = a; // need to disallow
va[] = [0]; // corrupt a[0]
assert(a[0].i == 5); // fails
}
struct S
{
const int i;
}
Should be disallowed with -preview=fixImmutableConv.
--
More information about the Digitalmars-d-bugs
mailing list