www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 24084] New: Add -nothrow Switch to Compiler

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

          Issue ID: 24084
           Summary: Add -nothrow Switch to Compiler
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: bugzilla digitalmars.com

dmd itself (and presumably others) do not throw Exceptions, preferring other
methods for dealing with errors. There is a cost, however, in supporting
Exceptions even when they are never thrown. The cost is in adding stack
unwinders for things like RAII objects, and preventing numerous optimizations
across try-catch boundaries.

Adding `nothrow` to all the code in a project turns out to be an inordinate
amount of work if the program is large. Putting `nothrow:` at the top of the
module doesn't influence the status for member functions in a class or struct,
the `nothrow:` will have to be repeated for each class/struct.

Taking a cue from gdc, it seems much more practical to add a -nothrow switch to
the compiler which doesn't add the stack unwinders and enables the
optimizations. This capability is already there for -betterC code, this would
just enable it for regular D code.

--
Aug 13 2023