From owner-cvs-all Fri Sep 7 6:18: 7 2001 Delivered-To: cvs-all@freebsd.org Received: from mailman.zeta.org.au (mailman.zeta.org.au [203.26.10.16]) by hub.freebsd.org (Postfix) with ESMTP id 0601737B407; Fri, 7 Sep 2001 06:18:00 -0700 (PDT) Received: from bde.zeta.org.au (bde.zeta.org.au [203.2.228.102]) by mailman.zeta.org.au (8.9.3/8.8.7) with ESMTP id XAA22434; Fri, 7 Sep 2001 23:17:33 +1000 Date: Fri, 7 Sep 2001 23:16:52 +1000 (EST) From: Bruce Evans X-X-Sender: To: Archie Cobbs Cc: Mark Murray , Maxim Sobolev , Mark Murray , , Subject: Re: cvs commit: src/usr.bin/su Makefile su.c In-Reply-To: <200109070423.f874Nnv16757@arch20m.dellroad.org> Message-ID: <20010907230542.I39011-100000@alphplex.bde.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-cvs-all@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Thu, 6 Sep 2001, Archie Cobbs wrote: > Bruce Evans writes: > > This question is sort of backwards too. You want to get const > > non-built-up stuff into a plain "char *". > > What about.. > > const char *foo = "foo"; > char *bar; > > *((const char **)&bar) = foo; > > or even just > > (const char *)bar = foo; /* gcc-ism? */ Ugh. I just shot down a patch by dd for using this gcc-ism. I think it's a bug in -Wcast-qual that either of the above breaks the warning. -Wcast-qual only claims to work for casts that remove qualifiers (from rvalues). The above casts add qualifiers (to lvalues). But this equivalent. There is also the uintptr_t hack which is used in a couple of places in libc. I prefer the union hack that Mark used in su.c. I think it is less likely to break in future versions of gcc, and less unportable. Bruce To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe cvs-all" in the body of the message