Thread overview
[Issue 19858] try with recursion fails to catch, possibly TCO gone too far
May 10, 2019
Ulrich Küttler
May 10, 2019
ag0aep6g
Dec 17, 2022
Iain Buclaw
May 10, 2019
https://issues.dlang.org/show_bug.cgi?id=19858

--- Comment #1 from Ulrich Küttler <kuettler@gmail.com> ---
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.

--
May 10, 2019
https://issues.dlang.org/show_bug.cgi?id=19858

elpenguino+D@gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |elpenguino+D@gmail.com

--- Comment #2 from elpenguino+D@gmail.com ---
This appears to be a regression introduced by the 2.066.0 release.

--
May 10, 2019
https://issues.dlang.org/show_bug.cgi?id=19858

ag0aep6g <ag0aep6g@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |wrong-code
                 CC|                            |ag0aep6g@gmail.com

--
July 13, 2020
https://issues.dlang.org/show_bug.cgi?id=19858

hsteoh@quickfur.ath.cx changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |hsteoh@quickfur.ath.cx

--
December 17, 2022
https://issues.dlang.org/show_bug.cgi?id=19858

Iain Buclaw <ibuclaw@gdcproject.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P1                          |P2

--