From owner-freebsd-chat Tue Apr 30 11:11:59 2002 Delivered-To: freebsd-chat@freebsd.org Received: from web20403.mail.yahoo.com (web20403.mail.yahoo.com [216.136.226.122]) by hub.freebsd.org (Postfix) with SMTP id 15A5137B417 for ; Tue, 30 Apr 2002 11:11:46 -0700 (PDT) Message-ID: <20020430181138.37192.qmail@web20403.mail.yahoo.com> Received: from [62.90.92.58] by web20403.mail.yahoo.com via HTTP; Tue, 30 Apr 2002 11:11:38 PDT Date: Tue, 30 Apr 2002 11:11:38 -0700 (PDT) From: Francis Jordan Subject: Re: strange gcc warning To: Dag-Erling Smorgrav Cc: freebsd-chat@freebsd.org In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Sender: owner-freebsd-chat@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org Hi Dag-Erling, The warning goes away when I wrap the array in a struct, but I still don't understand it clearly. If the array is converted to a pointer, isn't it safe to cast a regular pointer to a pointer to const (i.e. a read-only pointer)? If I write: void foo(const int *p) {} int main() { int *i = 0; foo(i); return 0; } there is no warning. Thanks FRJ --- Dag-Erling Smorgrav wrote: > Francis Jordan writes: > > This may seem like a newbie question, but still -- > why > > does the following produce a warning: > > > > void > > foo(const int b[8][8]) > > { > > } > > Arrays degenerate to pointers when passed as > arguments to functions. > You can wrap it in a struct if you want to keep the > size information; > otherwise foo() will have to do the necessary > pointer arithmetic "by > hand". > > DES > -- > Dag-Erling Smorgrav - des@ofug.org __________________________________________________ Do You Yahoo!? Yahoo! Health - your guide to health and wellness http://health.yahoo.com To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-chat" in the body of the message