From owner-freebsd-hackers Thu Jun 7 10:47:54 2001 Delivered-To: freebsd-hackers@freebsd.org Received: from shade.nectar.com (gw.nectar.com [208.42.49.153]) by hub.freebsd.org (Postfix) with ESMTP id E862937B406; Thu, 7 Jun 2001 10:47:49 -0700 (PDT) (envelope-from nectar@nectar.com) Received: (from nectar@localhost) by shade.nectar.com (8.11.3/8.11.3) id f57HlUR05191; Thu, 7 Jun 2001 12:47:30 -0500 (CDT) (envelope-from nectar) Date: Thu, 7 Jun 2001 12:47:30 -0500 From: "Jacques A. Vidrine" To: John Baldwin Cc: Peter Pentchev , hackers@FreeBSD.org Subject: Re: free() and const warnings Message-ID: <20010607124729.B4940@shade.nectar.com> References: <20010607195634.I724@ringworld.oblivion.bg> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: ; from jhb@FreeBSD.org on Thu, Jun 07, 2001 at 10:20:51AM -0700 X-Url: http://www.nectar.com/ Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Thu, Jun 07, 2001 at 10:20:51AM -0700, John Baldwin wrote: > > On 07-Jun-01 Peter Pentchev wrote: > > On Thu, Jun 07, 2001 at 07:07:22PM +0300, Peter Pentchev wrote: > >> Hi, > >> > >> Is free((void *) (size_t) ptr) the only way to free a const whatever *ptr > >> with WARNS=2? (or more specifically, with -Wcast-qual) > > > > Uhm. OK. So size_t may not be enough to hold a pointer. What is it then - > > caddr_t? > > uintptr_t for data pointers. In theory I think code pointers may not fit in a > uintptr_t. C99 says of uintptr_t only that for any valid pointer p, the following is true: (void *)(uintptr_t)p == (void *)p Likewise for intptr_t. I read that as covering both code and data pointers. Of course, who's to say the way uintptr_t is implemented on our platform adheres to the same rules :-) > free((void *)(uintptr_t)ptr) should work. > > Of course, this begs the question of why you are free'ing a const. :) Indeed! Cheers, -- Jacques Vidrine / n@nectar.com / jvidrine@verio.net / nectar@FreeBSD.org To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message