This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: c++/8543: bus error with 2 word alignments


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]