[Issue 22397] Out of memory during compilation

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Oct 16 16:50:56 UTC 2021


https://issues.dlang.org/show_bug.cgi?id=22397

--- Comment #5 from Vladimir Panteleev <dlang-bugzilla at thecybershadow.net> ---
Maybe something like this to avoid saying that out-of-memory errors are
compiler bugs:

diff --git a/src/dmd/mars.d b/src/dmd/mars.d
index 54c8298ea9..344ad207e2 100644
--- a/src/dmd/mars.d
+++ b/src/dmd/mars.d
@@ -1064,10 +1064,18 @@ else
             dmd_coverSetMerge(true);
         }

-        scope(failure) stderr.printInternalFailure;
-
-        auto args = Runtime.cArgs();
-        return tryMain(args.argc, cast(const(char)**)args.argv,
global.params);
+        try
+        {
+            auto args = Runtime.cArgs();
+            return tryMain(args.argc, cast(const(char)**)args.argv,
global.params);
+        }
+        catch (OutOfMemoryError e)
+            throw e;
+        catch (Throwable e)
+        {
+            stderr.printInternalFailure;
+            throw e;
+        }
     }
 } // !NoMain

--


More information about the Digitalmars-d-bugs mailing list