From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5415 invoked by alias); 17 Sep 2014 18:05:55 -0000 Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org Received: (qmail 5404 invoked by uid 89); 17 Sep 2014 18:05:55 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-4.2 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Wed, 17 Sep 2014 18:05:48 +0000 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s8HI5kh8010380 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 17 Sep 2014 14:05:47 -0400 Received: from zebedee.pink ([10.3.113.10]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s8HI5iSI022814; Wed, 17 Sep 2014 14:05:45 -0400 Message-ID: <5419CD78.9040703@redhat.com> Date: Wed, 17 Sep 2014 18:05:00 -0000 From: Andrew Haley User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.8.0 MIME-Version: 1.0 To: "Andy Falanga (afalanga)" , Jonathan Wakely CC: "gcc-help@gcc.gnu.org" Subject: Re: Possible bug in gcc 4.4.7 References: <60F6FAE47D1BCE4380CC06D18F49789B93F81C6E@NTXBOIMBX02.micron.com> <60F6FAE47D1BCE4380CC06D18F49789B93F81CD4@NTXBOIMBX02.micron.com> In-Reply-To: <60F6FAE47D1BCE4380CC06D18F49789B93F81CD4@NTXBOIMBX02.micron.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-IsSubscribed: yes X-SW-Source: 2014-09/txt/msg00097.txt.bz2 On 09/17/2014 06:15 PM, Andy Falanga (afalanga) wrote: > Ha, nothing except my thinking that, because I was casting a > reference, I had to use reinterpret_cast<>. Of course, that (your > suggestion) worked for me. Please point me to the correct section > of the language spec so that I might better understand why this is > undefined behavior. Here's the C version: "6.5 Expressions": An object shall have its stored value accessed only by an lvalue expression that has one of the following types: a type compatible with the effective type of the object, a qualified version of a type compatible with the effective type of the object, a type that is the signed or unsigned type corresponding to the effective type of the object, a type that is the signed or unsigned type corresponding to a qualified version of the effective type of the object, an aggregate or union type that includes one of the aforementioned types among its members (including, recursively, a member of a subaggregate or contained union), or a character type. C++ uses the same rule. If you access an object using an lvalue expression of an incompatible type, all bets are off. static_cast(reinterpret_cast(f1) is an example of such an expression. Andrew.