[llvm-dev] clang-tidy false positives with common realloc/malloc sizeof pattern
ell1e via llvm-dev
llvm-dev at lists.llvm.org
Tue Dec 8 00:13:36 PST 2020
oops, just realizing this probably should go to llvm-bugs@ or similar,
my bad. Should I resend it to over there? I apologize for the noise
On 12/8/20 9:11 AM, ell1e wrote:
>
>
> 451: h64expression **new_arg_values = realloc(
> 452: out_funcargs->arg_value,
> 453: sizeof(*new_arg_values) * (out_funcargs->arg_count + 1)
> 454: );
> (line 453) Suspicious usage of 'sizeof(A*)'; pointer to aggregate
>
>
> I have this clang-tidy false positive ALL OVER my code base, and it's
> drowning the useful warnings. Also, I agree that sizeof(pointer) looks
> suspicious in many cases, just not this one.
>
> TYPE *target = realloc(..., sizeof(*target) ...)
>
> is such a common pattern, even when TYPE happens to be a pointer type
> itself, I don't think this should show up with that warning. Or is it
> just me? Would love to see this improved one day.
>
> I'm happy to be educated though why this code actually is bad/suspicious
> for real. I just really don't see it, so the warning bugs me -
> especially since if I actually misuse sizeof() now there is no way I
> could actually spot the warning among all the uninteresting ones.
>
> Regards,
>
> ell1e
>
More information about the llvm-dev
mailing list