https://gcc.gnu.org/bugzilla/show_bug.cgi?id=25702
--- Comment #14 from Jonathan Wakely <redi at gcc dot gnu.org> --- See PR 71219 and the TC it links to. The suggestion is to warn for (T*)malloc(n) where n < sizeof(T) i.e. when there is enough context to infer that what was intended was malloc(sizeof(T)). The occurrence of sizeof(p) in the example is not essential to the point, it's just a common way that the bug happens.