[cfe-dev] [ MallocSizeofChecker ] - False positive about MallocSizeofChecker

Joerg Sonnenberger via cfe-dev cfe-dev at lists.llvm.org
Mon Sep 4 01:45:45 PDT 2017


On Mon, Sep 04, 2017 at 03:23:10AM +0000, Wong Henry via cfe-dev wrote:
>     warning: Result of 'malloc' is converted to a pointer of type 'unsigned int', which is incompatible with sizeof operand type 'int'
>             ptr = (unsigned int*)malloc(sizeof(int) * 12);

I think it works perfectly correct here. There is a reason why the
common idiom is to use sizeof(*ptr) in this case.

Joerg



More information about the cfe-dev mailing list