[Bug c/25702] feature request: generate a warning for sizeof on a pointer
redi at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Sat May 21 17:23:00 GMT 2016
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.
More information about the Gcc-bugs
mailing list