https://gcc.gnu.org/bugzilla/show_bug.cgi?id=25702
--- Comment #15 from Jakub Jelinek ---
Even (T*)malloc(n) where n < sizeof(T) is quite common, e.g. in GCC itself
(well, we don't usually use malloc but some ggc_alloc*) - e.g. if T is a union
and the code wants to allocate memory just for one of
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=25702
--- Comment #14 from Jonathan Wakely ---
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
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=25702
--- Comment #13 from Jakub Jelinek ---
If we add such a warning, IMNSHO it shouldn't be in -Wall, because sizeof on
pointer is a perfectly valid thing, which is used in huge amounts of code,
there is really nothing wrong on it.
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=25702
--- Comment #12 from Jonathan Wakely ---
PR 71219 requests a new warning for:
struct S* p = (struct S*)malloc(sizeof(p));
which would solve some of the other bugs shown in comment 3.
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=25702
--- Comment #11 from Mark Eklund ---
-Wsizeof-pointer-memaccess is definitely a good targeted fix and probably hits
a majority of what I've seen. I'm good with this being resolved.
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=25702
Marek Polacek changed:
What|Removed |Added
Status|NEW |RESOLVED
CC|
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25702
Jakub Jelinek changed:
What|Removed |Added
CC||jakub at gcc dot gnu.org
--- Co
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25702
David Csirmaz changed:
What|Removed |Added
CC||forgcc at calmarius dot net
---
--- Comment #7 from steven at gcc dot gnu dot org 2009-08-08 22:35 ---
I believe this should be closed as WONTFIX. Warnings exist to indicate things
in the program that are almost certainly wrong. In this case, the only way to
really avoid false positives is to look at the context of t
--- Comment #6 from pinskia at gcc dot gnu dot org 2008-11-14 23:51 ---
Actually I use sizeof all the time on pointers so I don't think this is useful.
In fact it falls down with meta programming.
That is:
#define bitcase(type, a) ({typeof (a) b = a; type c; int
notthesamesize[sizeof(a
--
rguenth at gcc dot gnu dot org changed:
What|Removed |Added
CC||marcus at jet dot franken
|
--- Comment #5 from meklund at cisco dot com 2007-11-28 19:43 ---
Subject: Re: feature request: generate a warning for sizeof on a pointer
Hi Manu,
This is in regards to your Comments for the gcc feature enhancement
request, http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25702.
On Wed,
--- Comment #4 from manu at gcc dot gnu dot org 2007-11-28 17:34 ---
So what the BSD people said about this? Did they agree with your assessment?
How many of those 26 likely bugs were considered "real" bugs by them?
It really seems too noisy and with no clear way to avoid or workaround
--- Comment #3 from meklund at cisco dot com 2006-01-17 15:36 ---
Subject: Re: feature request: generate a warning for sizeof on a pointer
Using the FreeBSD latest CVS pull on 10-Jan-06 (5.4 based), a build world
was run with the below modifications to GCC. The output was then evaluat
--- Comment #2 from meklund at cisco dot com 2006-01-06 22:24 ---
Subject: Re: feature request: generate a warning for sizeof on a pointer
On Fri, Jan 06, 2006 at 10:12:55PM -, pinskia at gcc dot gnu dot org wrote:
> Actually people use sizeof(x) all the time to mean the correct th
--- Comment #1 from pinskia at gcc dot gnu dot org 2006-01-06 22:12 ---
Actually people use sizeof(x) all the time to mean the correct thing, for an
example: memcpy(&x, y, sizeof(x));
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25702
16 matches
Mail list logo