From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6736 invoked by alias); 21 Oct 2002 13:52:21 -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 6729 invoked from network); 21 Oct 2002 13:52:20 -0000 Received: from unknown (HELO mail.enyo.de) (212.9.189.162) by sources.redhat.com with SMTP; 21 Oct 2002 13:52:20 -0000 Received: from [212.9.189.171] (helo=deneb.enyo.de) by mail.enyo.de with esmtp (Exim 3.34 #2) id 183cyN-0000wd-00; Mon, 21 Oct 2002 15:51:59 +0200 Received: from fw by deneb.enyo.de with local (Exim 3.34 #4) id 183cyU-0000Zm-00; Mon, 21 Oct 2002 15:52:06 +0200 To: John Love-Jensen Cc: Claudio Bley , Joshua Nye , Steve Dondley , Subject: Re: Avoiding "assignment from incompatible pointer type" warning References: From: Florian Weimer Mail-Followup-To: John Love-Jensen , Claudio Bley , Joshua Nye , Steve Dondley , Date: Mon, 21 Oct 2002 06:52:00 -0000 In-Reply-To: (John Love-Jensen's message of "Mon, 21 Oct 2002 08:40:48 -0500") Message-ID: <87d6q3vr09.fsf@deneb.enyo.de> User-Agent: Gnus/5.090008 (Oort Gnus v0.08) Emacs/21.2 (i686-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-SW-Source: 2002-10/txt/msg00243.txt.bz2 John Love-Jensen writes: >> 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? > > You are correct, the casting is fine, insofar as the given code snippet > goes. > > I assume the complaint/concern was regarding the (presumed) > dereferencing of the int* p at some later point in the code. Oh, please. An implementation is free to consider such pointer conversions to be undefined (of course, an implementation may do something useful nevertheless), so it's essentially undefined. And the undefined behavior is triggered upon the cast, not when the pointer is dereferenced. 6.3.2.3(7) only ensures that conforming implementations may not issue a diagnostic for such programming errors.