Bug 19858 – try with recursion fails to catch, possibly TCO gone too far

Status
NEW
Severity
major
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2019-05-10T07:37:01Z
Last change time
2024-12-13T19:03:21Z
Keywords
wrong-code
Assigned to
No Owner
Creator
Ulrich Küttler
Moved to GitHub: dmd#17906 →

Comments

Comment #0 by kuettler — 2019-05-10T07:37:01Z
Comment #1 by kuettler — 2019-05-10T07:41:42Z
Here is a piece of code that should be good but fails: import std.stdio; int eval(int c) { if (c > 0) { try { //writeln("Try harder!"); return eval(c - 1); } catch (Exception e) { writeln("GOOD ", c, ": ", e.msg); return 0; } } else { throw new Exception("Something exceptional right here"); } } int main() { try { return eval(1); } catch (Exception e) { writeln("FAILED: ", e.msg); } return 1; } Fun thing is, you can ask dmd to try harder (uncomment above) at it works. Same behavior seen with ldc2 and gdc.
Comment #2 by elpenguino+D — 2019-05-10T07:48:50Z
This appears to be a regression introduced by the 2.066.0 release.
Comment #3 by robert.schadek — 2024-12-13T19:03:21Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/17906 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB