Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 7 Sep 2001 23:16:52 +1000 (EST)
From:      Bruce Evans <bde@zeta.org.au>
To:        Archie Cobbs <archie@dellroad.org>
Cc:        Mark Murray <mark@grondar.za>, Maxim Sobolev <sobomax@FreeBSD.org>, Mark Murray <markm@FreeBSD.org>, <cvs-committers@FreeBSD.org>, <cvs-all@FreeBSD.org>
Subject:   Re: cvs commit: src/usr.bin/su Makefile su.c
Message-ID:  <20010907230542.I39011-100000@alphplex.bde.org>
In-Reply-To: <200109070423.f874Nnv16757@arch20m.dellroad.org>

next in thread | previous in thread | raw e-mail | index | archive | help
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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20010907230542.I39011-100000>