-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Description
I decided to revisit the use of clang-tidy on the C++ code. As I browsed through the warnings I came across an issue involving an allocation of zero bytes. So, I just updated the util.hpp
code to check for zero sized allocations, and in those cases return nullptr
. When running the zig tests, I hit an assertion, tried tweaking it, hit another assertion, etc. So instead of going through the whole process of cleaning this up on my own (probably incorrectly), let me show you the code and the failed assertions. If this is a real issue, I'd be happy to follow up on it. I will submit the diff in a PR momentarily.
EDIT: The reason this is non-portable behavior is that malloc
on zero is allowed to return null. It seems on the platforms used to test zig, this is not the case. A special pointer is returned with a non-null value. That is the only way I can explain the assertions failing when returning null.