From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14883 invoked by alias); 18 Nov 2002 18:12:42 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 14818 invoked by uid 61); 18 Nov 2002 18:12:39 -0000 Date: Sat, 23 Nov 2002 00:30:00 -0000 Message-ID: <20021118181227.14712.qmail@sources.redhat.com> To: gcc-bugs@gcc.gnu.org, gcc-prs@gcc.gnu.org, massimo.ravasi@epfl.ch, nobody@gcc.gnu.org From: bangerth@dealii.org Reply-To: bangerth@dealii.org, gcc-bugs@gcc.gnu.org, gcc-prs@gcc.gnu.org, massimo.ravasi@epfl.ch, nobody@gcc.gnu.org, gcc-gnats@gcc.gnu.org Subject: Re: c++/8543: bus error with 2 word alignments X-SW-Source: 2002-11/txt/msg00882.txt.bz2 List-Id: Synopsis: bus error with 2 word alignments State-Changed-From-To: open->analyzed State-Changed-By: bangerth State-Changed-When: Mon Nov 18 10:11:12 2002 State-Changed-Why: I can confirm this. However, from my limited understanding, what you do is not legal. You try something like long long i; long long *p = (long long *)((char*)&i + 4); *p = 0; As far as I can tell, trying to play games with pointers and not obeying to the alignment rules of the types they point to is invoking undefined behavior, and a bus error is undefined behavior. That you get varying results with various flags and other parts of code is to be expected then (after all, a working program is a valid interpretation of "undefined behavior"). Maybe someone can clarify on the pointer alignment issue? http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=8543