digitalmars.D.bugs - [Issue 2695] New: pure functions can invoke impure function pointers
- d-bugmail puremagic.com (29/29) Feb 27 2009 http://d.puremagic.com/issues/show_bug.cgi?id=2695
- d-bugmail puremagic.com (12/12) Apr 22 2009 http://d.puremagic.com/issues/show_bug.cgi?id=2695
- d-bugmail puremagic.com (11/11) May 14 2009 http://d.puremagic.com/issues/show_bug.cgi?id=2695
http://d.puremagic.com/issues/show_bug.cgi?id=2695 Summary: pure functions can invoke impure function pointers Product: D Version: 2.025 Platform: PC OS/Version: Windows Status: NEW Keywords: accepts-invalid Severity: normal Priority: P2 Component: DMD AssignedTo: bugzilla digitalmars.com ReportedBy: clugdbug yahoo.com.au This compiles, and it shouldn't. Interestingly, if you replace 'pure' with 'nothrow', the code is correctly rejected. -------- static int nasty; int impure_evil_function(int x) { nasty++; return nasty; } pure int foo(int x) { int function(int) a = &impure_evil_function; return a(x); } -------- --
Feb 27 2009
http://d.puremagic.com/issues/show_bug.cgi?id=2695 Created an attachment (id=334) --> (http://d.puremagic.com/issues/attachment.cgi?id=334&action=view) Patch for DMD2.029. This patch also prevents pure functions from calling impure delegates. It (correctly) does not prevent them from assigning to impure function pointers/delegates -- it just mustn't call them. I've tested it with delegates/functions passed as parameters, as well as defined as variables; I've also tested it with template functions, and with structs defining opCall, and made sure it doesn't cause problems with variables defined in module scope. --
Apr 22 2009
http://d.puremagic.com/issues/show_bug.cgi?id=2695 Don <clugdbug yahoo.com.au> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |FIXED Fixed DMD2.030 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
May 14 2009