public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug regression/28373]  New: C code gives "unaligned access"
@ 2006-07-13 20:26 kminola at eng dot umd dot edu
  2006-07-13 20:59 ` [Bug regression/28373] " falk at debian dot org
  2006-07-13 22:45 ` pinskia at gcc dot gnu dot org
  0 siblings, 2 replies; 3+ messages in thread
From: kminola at eng dot umd dot edu @ 2006-07-13 20:26 UTC (permalink / raw)
  To: gcc-bugs

/*  gcc-4.1.1 gives "unaligned access" on alphaev68-dec-osf5.1b
    regression from gcc-3.4.4

% gcc -v
Using built-in specs.
Target: alphaev68-dec-osf5.1b
Configured with: /usr/local/gcc-4.1.1/src/gcc-4.1.1/configure
--enable-languages=c --prefix=/usr/local/gcc-4.1.1/alpha-OSF1-V5
Thread model: posix
gcc version 4.1.1
%
%
gcc -o foo foo.c
% foo
Unaligned access pid=141992 <foo> va=0x11fffbffc pc=0x12000115c ra=0x1200011a0
inst=0x
9d420000
% 
*/

typedef struct
{
    double    d;
} aa;

int foo(v)
aa *v;
{
    v->d = (double) 1;

  return 0;
}

int main()
{
    int cc[1];
    int i1;
    int i2;
    int i3;
    int i4;
    int i5;
    int i6;
    int i7;   /* if remove this line, then no problem! */

    foo(cc);  /* says "unaligned access" */

    return 0;
}


-- 
           Summary: C code gives "unaligned access"
           Product: gcc
           Version: 4.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: regression
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: kminola at eng dot umd dot edu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28373


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug regression/28373] C code gives "unaligned access"
  2006-07-13 20:26 [Bug regression/28373] New: C code gives "unaligned access" kminola at eng dot umd dot edu
@ 2006-07-13 20:59 ` falk at debian dot org
  2006-07-13 22:45 ` pinskia at gcc dot gnu dot org
  1 sibling, 0 replies; 3+ messages in thread
From: falk at debian dot org @ 2006-07-13 20:59 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from falk at debian dot org  2006-07-13 20:58 -------
The conversion from int* to aa* is only defined if the pointer is correctly
aligned. Even if it was correctly aligned, dereferencing this pointer is 
undefined behavior (see -Wstrict-aliasing documentation). So this is not a gcc
bug.


-- 

falk at debian dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28373


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug regression/28373] C code gives "unaligned access"
  2006-07-13 20:26 [Bug regression/28373] New: C code gives "unaligned access" kminola at eng dot umd dot edu
  2006-07-13 20:59 ` [Bug regression/28373] " falk at debian dot org
@ 2006-07-13 22:45 ` pinskia at gcc dot gnu dot org
  1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-07-13 22:45 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from pinskia at gcc dot gnu dot org  2006-07-13 22:44 -------
More than that:
    int cc[1];
    foo(cc);  /* says "unaligned access" */
int foo(v)
aa *v;

You are also violating C aliasing rules and also violating an even more
fundental problem in that the struct aa will not fit in cc.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28373


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2006-07-13 22:45 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-07-13 20:26 [Bug regression/28373] New: C code gives "unaligned access" kminola at eng dot umd dot edu
2006-07-13 20:59 ` [Bug regression/28373] " falk at debian dot org
2006-07-13 22:45 ` pinskia at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).