Bug 2054 – Const system broken on struct assignment.

Status
RESOLVED
Resolution
FIXED
Severity
critical
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2008-04-28T18:28:00Z
Last change time
2015-06-09T01:14:36Z
Keywords
accepts-invalid
Assigned to
bugzilla
Creator
bruno.do.medeiros+deebugz

Comments

Comment #0 by bruno.do.medeiros+deebugz — 2008-04-28T18:28:37Z
Const system broken on struct assignment: ---- ---- struct Struct { char* chptr; } void main() { char ch = 'd'; invariant Struct iStruct = {&ch}; Struct y = iStruct; // BREAKAGE *y.chptr = 'X'; // Because now we can do this } ---- ---- Like Andrei mentioned in accu-functional.pdf , such struct assignment should only be allowed if the struct refered to no mutable memory (which is not the case).
Comment #1 by simen.kjaras — 2008-04-28T19:07:50Z
(In reply to comment #0) > void main() > { > char ch = 'd'; > invariant Struct iStruct = {&ch}; I would believe this to be just as wrong. Mutable is not implicitly castable to invariant, and ch might change even though iStruct assumes it does not.
Comment #2 by bruno.do.medeiros+deebugz — 2008-04-28T20:54:10Z
(In reply to comment #1) > (In reply to comment #0) > > void main() > > { > > char ch = 'd'; > > invariant Struct iStruct = {&ch}; > I would believe this to be just as wrong. Mutable is not implicitly castable to > invariant, and ch might change even though iStruct assumes it does not. Duh me, that's right of course. Massive distraction of mine :S
Comment #3 by bugzilla — 2008-05-22T05:01:48Z
Fixed dmd 2.014