From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28139 invoked by alias); 14 Mar 2013 11:10:58 -0000 Received: (qmail 28128 invoked by uid 22791); 14 Mar 2013 11:10:57 -0000 X-SWARE-Spam-Status: No, hits=-3.9 required=5.0 tests=AWL,BAYES_00,KHOP_THREADED,RP_MATCHES_RCVD,TW_CP X-Spam-Check-By: sourceware.org Received: from smtp.ispras.ru (HELO smtp.ispras.ru) (83.149.199.79) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 14 Mar 2013 11:10:47 +0000 Received: from [10.10.3.121] (unknown [83.149.199.91]) by smtp.ispras.ru (Postfix) with ESMTP id 4301B22BBC; Thu, 14 Mar 2013 15:10:45 +0400 (MSK) Date: Thu, 14 Mar 2013 11:10:00 -0000 From: Alexander Monakov To: Benjamin De Kosnik cc: gcc-patches@gcc.gnu.org Subject: Re: [wwwdocs] gcc-4.8/porting_to.html In-Reply-To: <20130313172850.49f4b3d7@oakwood> Message-ID: References: <20130313022916.0728c82e@oakwood> <51404E84.3070903@net-b.de> <20130313172850.49f4b3d7@oakwood> User-Agent: Alpine 2.00 (LNX 1167 2008-08-23) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2013-03/txt/msg00497.txt.bz2 It still references memcpy in -Wsizeof-pointer-memaccess section. Let me suggest instead: To fix, properly pass the size of cleared memory as the last argument: either dereference the pointer argument to sizeof when clearing *one pointed-to element*, or in addition to that multiply sizeof(*p) by the number of elements to clear in the pointed-to array (which may not be known at the point of memset call without additional code changes). I suppose a good chunk of problematic code hitting this warning would be doing something like: void foo(int a[]) { memset(a, 0, sizeof(a)); } ... in which case dereferencing a in sizeof is probably the wrong thing to do. Alexander