From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11908 invoked by alias); 18 Feb 2011 18:31:42 -0000 Received: (qmail 11897 invoked by uid 22791); 18 Feb 2011 18:31:41 -0000 X-SWARE-Spam-Status: No, hits=-2.0 required=5.0 tests=AWL,BAYES_00,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from gate.crashing.org (HELO gate.crashing.org) (63.228.1.57) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 18 Feb 2011 18:31:34 +0000 Received: from gate.crashing.org (localhost.localdomain [127.0.0.1]) by gate.crashing.org (8.14.1/8.13.8) with ESMTP id p1IIVVQ7001748; Fri, 18 Feb 2011 12:31:31 -0600 Received: (from apache@localhost) by gate.crashing.org (8.14.1/8.14.1/Submit) id p1IIVV2D001742; Fri, 18 Feb 2011 19:31:31 +0100 Received: from 94.211.195.167 (SquirrelMail authenticated user segher) by gate.crashing.org with HTTP; Fri, 18 Feb 2011 19:31:31 +0100 (CET) Message-ID: <56330.94.211.195.167.1298053891.squirrel@gate.crashing.org> In-Reply-To: <34841.78061.qm@web130223.mail.mud.yahoo.com> References: <34841.78061.qm@web130223.mail.mud.yahoo.com> Date: Sat, 19 Feb 2011 09:41:00 -0000 Subject: Re: alias question From: "Segher Boessenkool" To: "xorbe" Cc: gcc-help@gcc.gnu.org User-Agent: SquirrelMail/1.4.10a-1.fc6 MIME-Version: 1.0 Content-Type: text/plain;charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-IsSubscribed: yes 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 X-SW-Source: 2011-02/txt/msg00291.txt.bz2 >> But not every type aliases character type! > > What? You can access any type with a char type, > this is a specific exception. Yes. And you cannot access a char as any type. The exception is not symmetric in that way. > Here's a concrete example. > const short *w((short*)b); That's not C code. I have no idea about the rules in C++.. > char b[4] = {0,0,0,0}; If it was C, then the objects b[...] have declared type "char", so you are only allowed to access it as a character type; anything else results in undefined behaviour. Segher