This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c/25702] feature request: generate a warning for sizeof on a pointer


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.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]