Thread overview | ||||||
---|---|---|---|---|---|---|
|
September 18, 2010 [Issue 4891] New: Assignment from non-pure function to pure function pointer compiles when it shouldn't | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=4891 Summary: Assignment from non-pure function to pure function pointer compiles when it shouldn't 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 16:07:33 PDT --- Take this program struct S { public: this(int function(int) pure func) { _func = func; } @property int function(int) pure func() { return func; } private: int function(int) pure _func; } int add1(int num) { return num + 1; } void main() { auto s = S(&add1); } The construction of s should not compile because add1() is not a pure function. Granted, it could be pure if I declared it as such, but I didn't. And the compiler isn't figuring out that add1() could be pure and letting it through because of that because if I add a writeln() call to add1(), it still compiles. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
September 19, 2010 [Issue 4891] Assignment from non-pure function to pure function pointer compiles when it shouldn't | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jonathan M Davis | http://d.puremagic.com/issues/show_bug.cgi?id=4891 --- Comment #1 from Jonathan M Davis <jmdavisProg@gmx.com> 2010-09-18 17:15:25 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: ------- |
September 20, 2010 [Issue 4891] Assignment from non-pure function to pure function pointer compiles when it shouldn't | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jonathan M Davis | http://d.puremagic.com/issues/show_bug.cgi?id=4891 bearophile_hugs@eml.cc changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |bearophile_hugs@eml.cc --- Comment #2 from bearophile_hugs@eml.cc 2010-09-19 18:04:25 PDT --- See bug 3833 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
June 07, 2011 [Issue 4891] Assignment from non-pure function to pure function pointer compiles when it shouldn't | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jonathan M Davis | http://d.puremagic.com/issues/show_bug.cgi?id=4891 yebblies <yebblies@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |yebblies@gmail.com Resolution| |DUPLICATE --- Comment #3 from yebblies <yebblies@gmail.com> 2011-06-06 19:33:40 PDT --- This is a dupe of 3797, the purity of a function pointer (among other things) is not checked when performing implicit conversions. With dmd pull 88 you get the following error from dmd: testx.d(26): Error: constructor testx.S.this (int function(int) pure func) is no t callable using argument types (int function(int num)) testx.d(26): Error: cannot implicitly convert expression (& add1) of type int fu nction(int num) to int function(int) pure *** 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