3 ms·
No, the problem is that such a function is impossible to implement; any function that allocates memory can fail when no memory is available, and if the call fai
by dooglius 7y ago
No, the problem is that such a function is impossible to implement; any function that allocates memory can fail when no memory is available, and if the call fails there is no recourse in order to proceed per the spec. The compiler could easily create stub functions that call syscalls without the standard library's involvement if it wanted to (it needs to support freestanding environments, after all).
- saagarjha 7y agoAny function call can fail already: if you’ve overflowed the stack there’s not much you can do.
- dooglius 7y agoTrue, but for reliable programs, generally a separate tool will be used to statically ensure this can't happen (e.g. checkstack.pl for the Linux kernel), and these existing tools wouldn't know to parse this a new alternative allocation structure.