From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7429 invoked by alias); 21 Oct 2002 11:22:07 -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 7419 invoked from network); 21 Oct 2002 11:22:05 -0000 Received: from unknown (HELO wh2-19.st.uni-magdeburg.de) (141.44.162.19) by sources.redhat.com with SMTP; 21 Oct 2002 11:22:05 -0000 Received: by wh2-19.st.uni-magdeburg.de (Postfix, from userid 1000) id 453B190F60; Mon, 21 Oct 2002 13:22:25 +0200 (CEST) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <15795.58223.521979.895246@wh2-19.st.uni-magdeburg.de> Date: Mon, 21 Oct 2002 04:22:00 -0000 From: "Claudio Bley" To: Florian Weimer Cc: "Joshua Nye" , "Steve Dondley" , Subject: Re: Avoiding "assignment from incompatible pointer type" warning In-Reply-To: <87r8ekumlc.fsf@deneb.enyo.de> References: <000d01c272d5$85368b20$0100a8c0@windows9q3yn19> <87adlidm9l.fsf@deneb.enyo.de> <001801c27478$0ee5e480$c800a8c0@pdc1.boxcarmedia.com> <87r8ekumlc.fsf@deneb.enyo.de> X-SW-Source: 2002-10/txt/msg00234.txt.bz2 >>>>> "Florian" == Florian Weimer writes: Florian> "Joshua Nye" writes: >>> > int *p; >>> > float g = 3.141592653589793238; >>> > p = (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? -- Claudio Bley ASCII ribbon campaign (") Debian GNU/Linux advocate - against HTML email X http://www.cs.uni-magdeburg.de/~bley/ & vCards / \