Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign uptype of calloc in stdlib_checked.h #413
Comments
|
Here, the type of
And we hit the following condition in On relaxing this condition for @dtarditi Could you please comment on what the intended behavior should be in this case? |
|
Mike, If we re-write |
|
I can't think of a better solution. What will you call it? |
In
stdlib_checked.hthe functioncallocis defined thus:but this type fails to recognize that since the returned memory is zeroed out, we can treat the buffer as an
_Nt_array_ptrinstead. Would the following type be acceptable?I tried to use this type and the compiler rejected it, saying
Another problem I can see is that a normal array pointer would be allocated as an NT array pointer first, which could then be cast to the normal one. But doing so would cause the length to drop by one. I.e., a
_Nt_array_ptr<char> : count(3)actually represents a buffer of size 4, but you can only cast it to_Array_ptr<char> : count(3)so that the alias cannot be used to destroy the 0 terminator.