Thread overview |
---|
April 28, 2008 [Issue 2054] New: Const system broken on struct assignment. | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=2054 Summary: Const system broken on struct assignment. Product: D Version: 2.012 Platform: PC OS/Version: Windows Status: NEW Keywords: accepts-invalid Severity: critical Priority: P1 Component: DMD AssignedTo: bugzilla@digitalmars.com ReportedBy: brunodomedeiros+bugz@gmail.com 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). -- |
April 29, 2008 [Issue 2054] Const system broken on struct assignment. | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=2054 ------- Comment #1 from simen.kjaras@gmail.com 2008-04-28 19:07 ------- (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. -- |
April 29, 2008 [Issue 2054] Const system broken on struct assignment. | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=2054 ------- Comment #2 from brunodomedeiros+bugz@gmail.com 2008-04-28 20:54 ------- (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 -- |
May 22, 2008 [Issue 2054] Const system broken on struct assignment. | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=2054 bugzilla@digitalmars.com changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |FIXED ------- Comment #3 from bugzilla@digitalmars.com 2008-05-22 05:01 ------- Fixed dmd 2.014 -- |
Copyright © 1999-2021 by the D Language Foundation