-
Couldn't load subscription status.
- Fork 15k
Description
The newly added warning via #150028 is causes warning in unexpected situation.
Please see the following godbolt example.
In this example in line 12 the warning is generated, however the C99 standard clearly says:
" 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."
And clang implementation is to return NULL pointer in such case.
Thus the warning should be consistent with clang implementation currently existing and not generate warning when realloc() is used in lieu of free().
I propose to remove the warning in case of realloc() function is receiving a zero as a second parameter.
I agree on the fact of use realloc(p, NULL) instead of free(p) is being a terrible practice, but the existing warning is confusing to to the users.