www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 19164] New: malloc may be considered pure when failure

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

          Issue ID: 19164
           Summary: malloc may be considered pure when failure results in
                    program exit (no need to reset errno)
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: phobos
          Assignee: nobody puremagic.com
          Reporter: n8sh.secondary hotmail.com

A common pattern is to call `core.memory.pureMalloc` and either `assert(false)`
or `onOutOfMemoryError()` if allocation fails. In those places instead using
`malloc` directly (privately annotated as `pure`) would avoid a small amount of
work: the `core.memory.pureMalloc` wrapper reads errno, calls malloc, then
resets errno, which is unnecessary if allocation failure results in the program
exiting at once.

--
Aug 13 2018