[Issue 19164] malloc may be considered pure when failure results in program exit (no need to reset errno)

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Nov 18 08:44:31 UTC 2018


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

--- Comment #9 from Stanislav Blinov <stanislav.blinov at gmail.com> ---
It's like we're talking about different things... `malloc` returning null is
*insufficient* to warrant program termination, no matter how you want to call
the wrapper.

As for that:

> They can know by opening std.internal.memory and looking at what `enforceMalloc` does. If they don't know then they should not use it!

No. Just hard no. From your own documentation:

```
Pure variants of C's memory allocation functions `malloc`, `calloc`, and
`realloc` that achieve purity by aborting the program on failure so
they never visibly change errno.
```

null result is not a failure when malloc's argument was 0. So either the
documentation is wrong, or the implementation is wrong.

--


More information about the Digitalmars-d-bugs mailing list