digitalmars.D.bugs - [Issue 11461] New: `Error`s are not thrown as `pure nothrow` functions are optimized out with "-O -release"
- d-bugmail puremagic.com (29/29) Nov 07 2013 https://d.puremagic.com/issues/show_bug.cgi?id=11461
- d-bugmail puremagic.com (13/13) Nov 14 2013 https://d.puremagic.com/issues/show_bug.cgi?id=11461
- d-bugmail puremagic.com (12/16) Nov 14 2013 https://d.puremagic.com/issues/show_bug.cgi?id=11461
- d-bugmail puremagic.com (6/6) Nov 15 2013 https://d.puremagic.com/issues/show_bug.cgi?id=11461
- d-bugmail puremagic.com (22/34) Nov 15 2013 https://d.puremagic.com/issues/show_bug.cgi?id=11461
- d-bugmail puremagic.com (7/8) Nov 15 2013 https://d.puremagic.com/issues/show_bug.cgi?id=11461
- d-bugmail puremagic.com (9/9) Nov 15 2013 https://d.puremagic.com/issues/show_bug.cgi?id=11461
- d-bugmail puremagic.com (9/9) Nov 15 2013 https://d.puremagic.com/issues/show_bug.cgi?id=11461
- d-bugmail puremagic.com (11/11) Nov 15 2013 https://d.puremagic.com/issues/show_bug.cgi?id=11461
- d-bugmail puremagic.com (24/26) Nov 15 2013 https://d.puremagic.com/issues/show_bug.cgi?id=11461
- d-bugmail puremagic.com (7/7) Nov 15 2013 https://d.puremagic.com/issues/show_bug.cgi?id=11461
- d-bugmail puremagic.com (12/18) Mar 22 2014 https://d.puremagic.com/issues/show_bug.cgi?id=11461
- d-bugmail puremagic.com (11/15) Mar 22 2014 https://d.puremagic.com/issues/show_bug.cgi?id=11461
- d-bugmail puremagic.com (15/25) Mar 22 2014 https://d.puremagic.com/issues/show_bug.cgi?id=11461
- d-bugmail puremagic.com (8/8) Mar 23 2014 https://d.puremagic.com/issues/show_bug.cgi?id=11461
- d-bugmail puremagic.com (10/10) Mar 23 2014 https://d.puremagic.com/issues/show_bug.cgi?id=11461
- d-bugmail puremagic.com (10/10) Mar 23 2014 https://d.puremagic.com/issues/show_bug.cgi?id=11461
https://d.puremagic.com/issues/show_bug.cgi?id=11461 Summary: `Error`s are not thrown as `pure nothrow` functions are optimized out with "-O -release" Product: D Version: D2 Platform: All OS/Version: All Status: NEW Keywords: wrong-code Severity: normal Priority: P2 Component: DMD AssignedTo: nobody puremagic.com ReportedBy: verylonglogin.reg gmail.com 11:15:14 MSK --- This program runs without errors if compiled with "-O -release" and `f` is strongly pure and `nothrow`: --- void f() pure nothrow { throw new Error(""); } void main() { f(); } --- So optimizer must not completely optimize out even `nothrow` strongly pure function calls as an `Error` still could be thrown or there could be a HLT instruction. -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Nov 07 2013
https://d.puremagic.com/issues/show_bug.cgi?id=11461 Martin Nowak <code dawg.eu> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |code dawg.eu Well, if a function has no side effect and does not produce a result or the result isn't used, there is no point in calling it. It's pretty harsh to demand that the compiler always calls such functions only to support the minor noreturn use-case. -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Nov 14 2013
https://d.puremagic.com/issues/show_bug.cgi?id=11461 09:26:02 MSK ---Well, if a function has no side effect and does not produce a result or the result isn't used, there is no point in calling it. It's pretty harsh to demand that the compiler always calls such functions only to support the minor noreturn use-case.Minor or no it is documented `pure` functions can throw and the compiler already consider `pure` but not `nothrow` functions as doing this (i.e. they aren't optimized out). So `nothrow` must be treated the same way as `nothrow` just means no recoverable `Exception`s are thrown. Breaking language changes are welcome but in a separate enhancement issue. Currently `onOutOfMemoryError` is no-op because of this and the issue should be fixed. -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Nov 14 2013
https://d.puremagic.com/issues/show_bug.cgi?id=11461 Interesting btw, such a function will either never or always throw an Error. -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Nov 15 2013
https://d.puremagic.com/issues/show_bug.cgi?id=11461 monarchdodra gmail.com changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |monarchdodra gmail.comI don't know... an "Error" isn't really considered as "observable program behavior", is it? If a function is (either strongly or weakly) pure, takes no reference arguments, and is nothrow, then it calling it will not have observable side effect, and can (and IMO should) be optimized out. This can be workaround simply by forcing the function to look like it can have "observable side effects", as so: //---- void f(void* = null) pure nothrow { throw new Error(""); } void main() { f(); } //---- -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------Well, if a function has no side effect and does not produce a result or the result isn't used, there is no point in calling it. It's pretty harsh to demand that the compiler always calls such functions only to support the minor noreturn use-case.Minor or no it is documented `pure` functions can throw and the compiler already consider `pure` but not `nothrow` functions as doing this (i.e. they aren't optimized out). So `nothrow` must be treated the same way as `nothrow` just means no recoverable `Exception`s are thrown. Breaking language changes are welcome but in a separate enhancement issue. Currently `onOutOfMemoryError` is no-op because of this and the issue should be fixed.
Nov 15 2013
https://d.puremagic.com/issues/show_bug.cgi?id=11461Interesting btw, such a function will either never or always throw an Error.The fix is fairly simple, we need a way to annotate noreturn functions. -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Nov 15 2013
https://d.puremagic.com/issues/show_bug.cgi?id=11461 Commit pushed to master at https://github.com/D-Programming-Language/druntime https://github.com/D-Programming-Language/druntime/commit/e68e2459bd9a977338837a7e784041de56b68516 Add issue 11461 workaround. Issue URL: https://d.puremagic.com/issues/show_bug.cgi?id=11461 -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Nov 15 2013
https://d.puremagic.com/issues/show_bug.cgi?id=11461 Commit pushed to master at https://github.com/D-Programming-Language/druntime https://github.com/D-Programming-Language/druntime/commit/0422e58d1bd6c86063f73b9ca372e5e16afd64b0 Add issue 11461 workaround. Issue URL: https://d.puremagic.com/issues/show_bug.cgi?id=11461 -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Nov 15 2013
https://d.puremagic.com/issues/show_bug.cgi?id=11461 Temtaime <temtaime gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |temtaime gmail.com Hi, guys. Maybe i'm too stupid, but how nothrow function can throw ? -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Nov 15 2013
https://d.puremagic.com/issues/show_bug.cgi?id=11461Hi, guys. Maybe i'm too stupid, but how nothrow function can throw ?D defines both "Exception" and "Error", which derive from "Throwable". "Exception", is what you know from C++: The standard thing that gets thrown around to notify things like database/io problems: Things that "happen" and need to be dealt with. They unwind the stack, destroy things on the stack, etc... "Error" is an entire other beast: They are C++'s "assert" in more powerful: They represent a critical error of the program state: corruption, out of memory, failed assertions. They represent something you *cannot* recover from, and are telling you the program needs to halt. Unlike an "Exception", "Error" will blast through the call stack, bypassing destructors, bypassing "nothrow" function, bypassing "catch(Exception)"... They are not meant to happen general, and shouldn't be "handled" in the general sense of the term. So long story short, an Error can be thrown from a nothrow function, because an Error doesn't trigger stack cleanup, which means there is no need to generate _Exceptio_ handling code". => "nothrow" means "will not throw _Exceptions_". I'd link some references, but the best I know of is TDPL. -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Nov 15 2013
https://d.puremagic.com/issues/show_bug.cgi?id=11461 Clear. Thanks very much for explanation. -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Nov 15 2013
https://d.puremagic.com/issues/show_bug.cgi?id=11461 Rainer Schuetze <r.sagitario gmx.de> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |r.sagitario gmx.de PDT ---Commit pushed to master at https://github.com/D-Programming-Language/druntime https://github.com/D-Programming-Language/druntime/commit/0422e58d1bd6c86063f73b9ca372e5e16afd64b0 Add issue 11461 workaround. Issue URL: https://d.puremagic.com/issues/show_bug.cgi?id=11461Any particular reason why "pure" isn't removed from the onOutOfMemoryError declaration in core.exception aswell? And for all the other error functions? -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Mar 22 2014
https://d.puremagic.com/issues/show_bug.cgi?id=11461 bearophile_hugs eml.cc changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |bearophile_hugs eml.ccOn this there is no DIP and perhaps not even an enhancement request. -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------Interesting btw, such a function will either never or always throw an Error.The fix is fairly simple, we need a way to annotate noreturn functions.
Mar 22 2014
https://d.puremagic.com/issues/show_bug.cgi?id=11461 Maybe the problem can be worked around by making the function(s) *weakly* pure?Instead of removing the "pure", which is a breaking change, since it would prevent pure functions from having an "onOutOfMemoryError", what about my suggestion for weak purity? void onOutOfMemoryError(void* dummy11461 = null) trusted pure nothrow; or just: void onOutOfMemoryError(void* = null) trusted pure nothrow; instead of void onOutOfMemoryError() trusted /* pure dmd BUG11461 */ nothrow; -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------Commit pushed to master at https://github.com/D-Programming-Language/druntime https://github.com/D-Programming-Language/druntime/commit/0422e58d1bd6c86063f73b9ca372e5e16afd64b0 Add issue 11461 workaround. Issue URL: https://d.puremagic.com/issues/show_bug.cgi?id=11461Any particular reason why "pure" isn't removed from the onOutOfMemoryError declaration in core.exception aswell? And for all the other error functions?
Mar 22 2014
https://d.puremagic.com/issues/show_bug.cgi?id=11461 PDT --- I agree, it seems the better workaround. Clever compilers might notice that the passed parameter introduces no sideeffects and might infer strong purity, though. -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Mar 23 2014
https://d.puremagic.com/issues/show_bug.cgi?id=11461 Rainer Schuetze <r.sagitario gmx.de> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |pull PDT --- https://github.com/D-Programming-Language/druntime/pull/753 -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Mar 23 2014
https://d.puremagic.com/issues/show_bug.cgi?id=11461 Commit pushed to master at https://github.com/D-Programming-Language/druntime https://github.com/D-Programming-Language/druntime/commit/2a50ceabb436d150ee4e6bfff299def58bc9e92c Workaround 11461: avoid strong purity inference by passing null pointer to onOutOfMemoryError -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Mar 23 2014