<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/78558>78558</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            Clang-tidy complaint "Suspicious usage of ‘sizeof(char*)’" when using `sizeof *arr` in `malloc`
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang-tidy
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          dmitry-kabanov
      </td>
    </tr>
</table>

<pre>
    Hi,

I have the following line in a C code:
```c
ffi_type **arg_types = malloc(num_total_args * sizeof(*arg_types));
```
and `clang-tidy` warn with `Suspicious usage of 'sizeof(A*)'; pointer to aggregate [bugprone-sizeof-expression]`.

As far as I understand, this form (using `*array` in `sizeof`) is idiomatic in C, to avoid code duplication with typing the type :smile: 
like this: `sizeof(ffi_type *)`.

I am not sure if it is a bug, but still decided to raise an issue here.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJxsU92OqzYQfhpzM0pkTEjggotstlH3ug-wGuwJTI-xkW02TZ--MkQ526MjWSB7_r75vhmMkQdH1In6TdTvBS5p9KEzE6fw2P3AHp3_KnpvHt2fLNRFyHchz9v3A0b8Ikgjwc1b6-_sBrDsCNgBwgW0NySqp7c4yu3o7X678Wd6zARCnYU6YxjWawRRvcOE1notVOOW6TP5hPYTwxCzL0T-l_xNqOZ7lFBtPtXbL8W2KzoDubJFN-wSm4c4SrhjcHDnNGbTX0ucWbNfIiwRBwJ_A6FOr1rnFWUr1ElUbzB7dokCJA84DIEGTASifuuXYQ7e0W6L29E_c6AY2TtRv4uj3H-n7xzhhgEwwgcszlCICZ0R6gJp5Ag3HyYQqllipjW3ktsNuGJnl1-e6LKpBY7Ahv2EiXW2X9ZMHvDLs1mlALPMljUm9s_G02POybOCmxTVOU5ss2iwgbT8g1Y869OrpGr-L1_7a3MfgBM4nyAugYBvwCkjROiXIQPrlwQxsbVgSLMhk6EG5EiADjjGhWCkQPvCdJVpqxYL6sqTrOuTKg9lMXbHGg3i0UitlSYylSZs6XTCRvb9odIFd0qqgyzLppRSqXJ_qMvqqI4HqUsyqj-Ig6QJ2e6t_Zr2PgzFWrc7NXXdFBZ7snHdC6W-TY5SeU9Cl4N2_TJEcZCWY4o_0yROlrrLKwa0n2aL7BIIpX47an8o0UjRNi9-9YjhSe3T1gql4D6Sg9dIbN6wTcbPuXhuz1EWS7DdmNKc5RPqKtR14DQu_V77SahrRvz87ebg_yadhLquLEShrisR_wUAAP__-2pLfg">