From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18218 invoked by alias); 21 Oct 2002 11:42:11 -0000 Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org Received: (qmail 18211 invoked from network); 21 Oct 2002 11:42:10 -0000 Received: from unknown (HELO smtp.web.de) (217.72.192.158) by sources.redhat.com with SMTP; 21 Oct 2002 11:42:10 -0000 Received: from [129.187.26.79] (helo=mephisto) by smtp.web.de with asmtp (WEB.DE(Exim) 4.75 #2) id 183awj-00030N-00 for gcc-help@gcc.gnu.org; Mon, 21 Oct 2002 13:42:10 +0200 Content-Type: text/plain; charset="iso-8859-1" From: Sebastian Huber To: gcc-help@gcc.gnu.org Subject: Re: Avoiding "assignment from incompatible pointer type" warning Date: Mon, 21 Oct 2002 04:42:00 -0000 References: <87r8ekumlc.fsf@deneb.enyo.de> <15795.58223.521979.895246@wh2-19.st.uni-magdeburg.de> In-Reply-To: <15795.58223.521979.895246@wh2-19.st.uni-magdeburg.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200210211342.07630.sebastian-huber@web.de> X-SW-Source: 2002-10/txt/msg00237.txt.bz2 On Monday 21 October 2002 04:22, Claudio Bley wrote: > >>>>> "Florian" =3D=3D Florian Weimer writes: > > Florian> "Joshua Nye" writes: > >>> > int *p; > >>> > float g =3D 3.141592653589793238; > >>> > p =3D (int *)&g; > >>> > >>> Is this code legal? I doubt it. > >> > >> What do you consider legal and why wouldn't it be? > > Florian> Casting a pointer from float to int can result in > Florian> undefined behavior on some implementations. > > I can't see why. Can you elaborate on that? I mean, casting on the > machine code level does just nothing - it's just "syntactic sugar" to > convince the compiler to be quiet. I think casting from one pointer > type to another does no harm at all. Am I wrong? Hello, I guess that today it doesn't matter. But what is, if the size of the point= ers=20 differ? You should use 'void*' which can store any pointer. Bye