This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: c++/8543: bus error with 2 word alignments
- From: bangerth at dealii dot org
- To: gcc-bugs at gcc dot gnu dot org, gcc-prs at gcc dot gnu dot org, massimo dot ravasi at epfl dot ch, nobody at gcc dot gnu dot org
- Date: 18 Nov 2002 18:12:27 -0000
- Subject: Re: c++/8543: bus error with 2 word alignments
- Reply-to: bangerth at dealii dot org, gcc-bugs at gcc dot gnu dot org, gcc-prs at gcc dot gnu dot org, massimo dot ravasi at epfl dot ch, nobody at gcc dot gnu dot org, gcc-gnats at gcc dot gnu dot org
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