logoalt Hacker News

david-gpulast Friday at 8:26 AM2 repliesview on HN

As per the specification, it has to be a unique pointer.

Being tasked to implement a specification typically means having to pass extensive conformance tests and having to answer for instances of noncompliance. You soon learn to follow the spec to the letter, to the best of your abilities, unless you can make a strong case to your management for each specific deviation.


Replies

magicalhippolast Friday at 1:55 PM

But the letter is non-specific. It doesn't clarify if unique refers to unique when compared to non-zero allocations, or unique when called multiple times.

The C99 standard[1] seems to have worded it more precisely:

If the size of the space requested is zero, the behavior is implementation- defined: either a null pointer is returned, or the behavior is as if the size were some nonzero value, except that the returned pointer shall not be used to access an object.

[1]: https://rgambord.github.io/c99-doc/sections/7/20/3/index.htm...

show 2 replies
minetest2048last Friday at 2:03 PM

This is embedded C where standard abuse is a thing: https://thephd.dev/conformance-should-mean-something-fputc-a...