digitalmars.D.bugs - [Issue 10852] New: function wrongly inferred pure in embeded function with function cast
- d-bugmail puremagic.com (60/60) Aug 19 2013 http://d.puremagic.com/issues/show_bug.cgi?id=10852
http://d.puremagic.com/issues/show_bug.cgi?id=10852 Summary: function wrongly inferred pure in embeded function with function cast Product: D Version: D2 Platform: All OS/Version: All Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: nobody puremagic.com ReportedBy: monarchdodra gmail.com Given: 1. A template function 2. An embedded function 3. A function cast inside the embedded function Given the above pre-requirements, the embedded function will (wrongly) see the cast function as pure, and be wrongly inferred: //---- //Impure function. Doesn't throw; not marked as such. void impureFun() {} void nothrowFun()() nothrow { void fun () nothrow { alias nothrow void function() StillImpure_t; (cast(StillImpure_t)&impureFun)(); }; fun(); } void main() pure { nothrowFun(); //PASSES! (shouldn't) } //---- Observations: If the function is not templated, things are refused correctly. If there is no embedded function, things are refused correctly. Interesting observation: If you try to explicitly mark the function as pure, then you *will* be shot down: //---- void nothrowFun()() nothrow { void fun () nothrow pure { alias nothrow void function() StillImpure_t; (cast(StillImpure_t)&impureFun)(); //(here) }; fun(); } //---- Error: pure function 'main.nothrowFun!().nothrowFun.fun' cannot call impure function pointer 'cast(void function() nothrow)& impureFun' -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Aug 19 2013