Thread overview | |||||
---|---|---|---|---|---|
|
September 19, 2010 [Issue 4893] New: Function pointer assignments ignore constness | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=4893 Summary: Function pointer assignments ignore constness Product: D Version: unspecified Platform: Other OS/Version: Linux Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: nobody@puremagic.com ReportedBy: jmdavisProg@gmx.com --- Comment #0 from Jonathan M Davis <jmdavisProg@gmx.com> 2010-09-18 17:13:04 PDT --- Take this program: struct S { public: this(int[] function(const int[])func) { _func = func; } @property int[] function(const int[]) func() { return func; } private: int[] function(const int[]) _func; } int[] add1(int[] num) { return num ~ 1; } void main() { auto s = S(&add1); } It shouldn't compile, but it does. add1() does not take a const int[] and therefore could theoretically modify its arguments (though it doesn't here), violating the type of the function pointer. Using in and immutable instead of const has the same problem. They compile when they shouldn't. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
September 19, 2010 [Issue 4893] Function pointer assignments ignore constness | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jonathan M Davis | http://d.puremagic.com/issues/show_bug.cgi?id=4893 --- Comment #1 from Jonathan M Davis <jmdavisProg@gmx.com> 2010-09-18 17:14:59 PDT --- Oh, there's an error in my example - func return func instead of _func, resulting infinite recursion and therefore a segfault. I could have removed that function for the bug report anyway. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
October 19, 2010 [Issue 4893] Function pointer assignments ignore constness | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jonathan M Davis | http://d.puremagic.com/issues/show_bug.cgi?id=4893 Sobirari Muhomori <dfj1esp02@sneakemail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |DUPLICATE --- Comment #2 from Sobirari Muhomori <dfj1esp02@sneakemail.com> 2010-10-19 11:03:16 PDT --- *** This issue has been marked as a duplicate of issue 3797 *** -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
Copyright © 1999-2021 by the D Language Foundation