From owner-svn-src-all@FreeBSD.ORG Thu Jul 25 15:10:45 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 25610143; Thu, 25 Jul 2013 15:10:45 +0000 (UTC) (envelope-from mdf356@gmail.com) Received: from mail-ob0-x236.google.com (mail-ob0-x236.google.com [IPv6:2607:f8b0:4003:c01::236]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id AD4022DED; Thu, 25 Jul 2013 15:10:44 +0000 (UTC) Received: by mail-ob0-f182.google.com with SMTP id wo10so1779442obc.13 for ; Thu, 25 Jul 2013 08:10:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; bh=+dbKJ7QqQNHVav7fADAFkOBwF5R6sLxGL5wKT5PkFrI=; b=u05iKsACftIpkOny1vtQvM4xQMvmyR7K/stvQoIkSVEETX3lzl+J3S4ICizpPxDwIs cuZiJXxdnt5nmnAV+BA3eY5UINuJOWgGsM3isImp5+LeDVlhatCF+DlYF9HtVwC0hRbq ZXcbF02kL36SQds2RA33+4oWF60EV5swPcxYyFnaYC2BZ4YOT8Sw33U0zW4rHVeGKG16 yXpm0qiiLUuKE83F4SEjbdiNUv2z2GrX64WHMvJsp4s81cuLgS4DCFsvMo/itaRPgzvI kR0VHTS6Y5qdTkFsVOTeH16Cwts7lc7b7D1jzCXIAMv9Ptgkb05g2eVIT+NgRXRZ3zNe jw5w== MIME-Version: 1.0 X-Received: by 10.182.61.105 with SMTP id o9mr37024526obr.54.1374765044049; Thu, 25 Jul 2013 08:10:44 -0700 (PDT) Sender: mdf356@gmail.com Received: by 10.182.162.65 with HTTP; Thu, 25 Jul 2013 08:10:43 -0700 (PDT) In-Reply-To: <73FCA347-5EB9-445F-A25C-D06CA137CBEE@FreeBSD.org> References: <201307250348.r6P3mbsG049595@svn.freebsd.org> <20130725171038.O841@besplex.bde.org> <51F0DDB0.7080102@bitfrost.no> <73FCA347-5EB9-445F-A25C-D06CA137CBEE@FreeBSD.org> Date: Thu, 25 Jul 2013 08:10:43 -0700 X-Google-Sender-Auth: VNQyFicQOCV41CUg5qQpxd75crA Message-ID: Subject: Re: svn commit: r253636 - head/sys/vm From: mdf@FreeBSD.org To: David Chisnall Content-Type: text/plain; charset=ISO-8859-1 X-Content-Filtered-By: Mailman/MimeDel 2.1.14 Cc: "src-committers@freebsd.org" , "svn-src-all@freebsd.org" , "svn-src-head@freebsd.org" , Tim Kientzle , Bruce Evans , Hans Petter Selasky X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 25 Jul 2013 15:10:45 -0000 On Thu, Jul 25, 2013 at 4:43 AM, David Chisnall wrote: > However(), memset is to be preferred in this idiom because the compiler > provides better diagnostics in the case of error: > > bzero.c:9:22: warning: 'memset' call operates on objects of type 'struct > foo' > while the size is based on a different type 'struct foo *' > [-Wsizeof-pointer-memaccess] > memset(f, 0, sizeof(f)); > ~ ^ > bzero.c:9:22: note: did you mean to dereference the argument to 'sizeof' > (and > multiply it by the number of elements)? > memset(f, 0, sizeof(f)); > ^ > > The same line with bzero(f, sizeof(f)) generates no error. > Isn't that a compiler bug? memset(p, 0, n) is the same as bzero(p, n). Why would the compiler warn on one and not the other? Does clang have a similar bias for memcpy versus bcopy? Thanks, matthew