From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5181 invoked by alias); 6 Jan 2006 22:24:37 -0000 Received: (qmail 5174 invoked by alias); 6 Jan 2006 22:24:35 -0000 Date: Fri, 06 Jan 2006 22:24:00 -0000 Message-ID: <20060106222435.5173.qmail@sourceware.org> X-Bugzilla-Reason: CC References: Subject: [Bug c/25702] feature request: generate a warning for sizeof on a pointer In-Reply-To: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "meklund at cisco dot com" Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2006-01/txt/msg00624.txt.bz2 List-Id: ------- 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 -0000, pinskia at gcc dot gnu dot org wrote: > Actually people use sizeof(x) all the time to mean the correct thing, for an > example: memcpy(&x, y, sizeof(x)); True, and that is why I'd like to make it an optional warning. People would be up in arms if it weren't optional. But, for people that want to avoid this easily missed problem, they could live with memcpy(&x, y, sizeof(xtype *)) I have seen one instance where people would consider it annoying: char *m[] = { "this", "is", "bothersome", "to", "some" }; int m_items = sizeof(m) / sizeof(*m); but once again, the avoidance of having unexpectedly short lengths would override the annoyance for many. How about I apply my patch and do a large build like BSD "make world" and come back with a listing of how prevalent the above is? --mark -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25702