|
Archives
D Programming
DD.gnu digitalmars.D digitalmars.D.bugs digitalmars.D.dtl digitalmars.D.ide digitalmars.D.dwt digitalmars.D.announce digitalmars.D.learn digitalmars.D.debugger C/C++ Programming
c++c++.announce c++.atl c++.beta c++.chat c++.command-line c++.dos c++.dos.16-bits c++.dos.32-bits c++.idde c++.mfc c++.rtl c++.stl c++.stl.hp c++.stl.port c++.stl.sgi c++.stlsoft c++.windows c++.windows.16-bits c++.windows.32-bits c++.wxwindows digitalmars.empire digitalmars.DMDScript electronics |
digitalmars.D.bugs - [Issue 2094] New: transitive const can be broken easily
http://d.puremagic.com/issues/show_bug.cgi?id=2094 Summary: transitive const can be broken easily Product: D Version: 2.012 Platform: PC URL: http://www.digitalmars.com/webnews/newsgroups.php?art_gr oup=digitalmars.D&article_id=71465 OS/Version: Windows Status: NEW Keywords: spec Severity: normal Priority: P2 Component: www.digitalmars.com AssignedTo: bugzilla digitalmars.com ReportedBy: terranium yandex.ru class A { private int[] Xrg; int[] rg() const { return Xrg; } } void f(invariant A a) { a.rg[0]=0; } -- May 11 2008
http://d.puremagic.com/issues/show_bug.cgi?id=2094 ------- Comment #1 from terranium yandex.ru 2008-06-17 09:40 ------- C++ solution: forces rg to have return type const int[] -- Jun 17 2008
http://d.puremagic.com/issues/show_bug.cgi?id=2094 ------- Comment #2 from 2korden gmail.com 2008-06-17 09:54 ------- It shouldn't be able to compile and in fact it doesn't (tested with DMD2.013): Error: cannot implicitly convert expression (this.Xrg) of type const(int[]) to int[] -- Jun 17 2008
http://d.puremagic.com/issues/show_bug.cgi?id=2094 ------- Comment #3 from terranium yandex.ru 2008-06-18 02:09 ------- So one should write two getters: const and non-const? -- Jun 18 2008
http://d.puremagic.com/issues/show_bug.cgi?id=2094 ------- Comment #4 from wbaxter gmail.com 2008-06-18 05:28 ------- (In reply to comment #3)So one should write two getters: const and non-const? Jun 18 2008
http://d.puremagic.com/issues/show_bug.cgi?id=2094 2korden gmail.com changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |INVALID ------- Comment #5 from 2korden gmail.com 2008-06-18 06:11 ------- Shall we close this one? -- Jun 18 2008
http://d.puremagic.com/issues/show_bug.cgi?id=2094 braddr puremagic.com changed: What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |REOPENED Resolution|INVALID | ------- Comment #6 from braddr puremagic.com 2008-06-18 11:18 ------- No. invariantness if f's arg isn't being preserved, so this is a hole that Walter should see. I've reopened. -- Jun 18 2008
http://d.puremagic.com/issues/show_bug.cgi?id=2094 ------- Comment #7 from wbaxter gmail.com 2008-06-19 01:05 ------- I was just browsing through WalterAndrei.pdf from last year's D conference, when I noticed the "return" storage class. I had forgotten about that one. So I was wrong about Walter not having endorsed any particular solution to the redundant const methods problem. The solution he proposed at the D conference was to have something like: const(char[]) capitalize(return const(char[]) s) { ... } -- Jun 18 2008
http://d.puremagic.com/issues/show_bug.cgi?id=2094 ------- Comment #8 from terranium yandex.ru 2008-06-19 02:42 ------- (In reply to comment #4)But in D you may need three, actually. invariant, const, and non-const. Jun 19 2008
http://d.puremagic.com/issues/show_bug.cgi?id=2094 ------- Comment #9 from wbaxter gmail.com 2008-06-19 07:19 ------- (In reply to comment #8)(In reply to comment #4)But in D you may need three, actually. invariant, const, and non-const. Jun 19 2008
|