c++/8543: bus error with 2 word alignments
bangerth@dealii.org
bangerth@dealii.org
Mon Nov 18 10:32:00 GMT 2002
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
More information about the Gcc-bugs
mailing list