[clang] [clang] Implement -Walloc-size diagnostic option (PR #150028)

via cfe-commits cfe-commits at lists.llvm.org
Thu Sep 11 12:53:33 PDT 2025


cmtice wrote:

I seem to have found an issue with this warning.  I have some code roughly like this:

if (var1 < 0)
    return;

var2 = malloc(sizeof(...) * var1).

I'm getting warnings complaining that  the malloc is assigning -8 instead of 8.  The only way it could be -8 would be if var1 was negative. But if var1 is negative the malloc never gets executed (because of the return above). So it's warning in a case that can't happen.

https://github.com/llvm/llvm-project/pull/150028


More information about the cfe-commits mailing list