>Submitter-Id:  net
>Originator:    Bernd Eckenfels <[EMAIL PROTECTED]>
>Organization:  The Debian Project
>Confidential:  no
>Synopsis:      
>Severity:      serious
>Priority:      medium
>Category:      target
>Class:         wrong-code
>Release:       3.2.1 (Debian) (Debian unstable)
>Environment:
System: Debian GNU/Linux (unstable)
Architecture: sparc
host: sparc-linux
gcc version 3.2.2 20021212 (Debian prerelease)
>Description:
[ Reported to the Debian BTS as report #136659.
  Please CC [EMAIL PROTECTED] on replies.
  Log of report can be found at http://bugs.debian.org/136659 ]
        

[ rechecked with gcc-3.2 CVS 20021212 ]

To add to my problem (reported on debian devel) here is a test program to
reproduce it:

Output with o=2 (unaligned)

[EMAIL PROTECTED]:~$ ./bla
Start of struct 0xeffffc70, content: a=aaaaaaaaaaaaaa rel-pos x=12 offset
o=2
Now we are going to memcpy dst=a+x+o=0xeffffc7e
result of a+x+o access: b=aaaabbbbbbbbbb
Now we are going to bcopy dst=&(tmp_iphdr->saddr)=0xeffffc7e
result of bcopy &(tmp_iphdr->saddr) access: b=aaaabbbbbbbbbb
Now we are going to memcpy dst=&(tmp_iphdr->saddr)=0xeffffc7e
Bus error

Output with o=4 (aligned)

[EMAIL PROTECTED]:~$ gcc -O2 -o bla bla.c
[EMAIL PROTECTED]:~$ ./bla
Start of struct 0xeffffc70, content: a=aaaaaaaaaaaaaa rel-pos x=12 offset
o=4
Now we are going to memcpy dst=a+x+o=0xeffffc80
result of a+x+o access: b=aaaabbbbbbbbbb
Now we are going to bcopy dst=&(tmp_iphdr->saddr)=0xeffffc80
result of bcopy &(tmp_iphdr->saddr) access: b=aaaabbbbbbbbbb
Now we are going to memcpy dst=&(tmp_iphdr->saddr)=0xeffffc80
result of memcpy &(tmp_iphdr->saddr) access: b=aaaabbbbbbbbbb

Note: in both cases the pointer to the target (of bcopy and memcpy) are the
same a+x+o=0xeffffc7e and &(tmp_iphdr->saddr)=0xeffffc7e. The first case
works with memcpy, the second doesnt. This looks clearly like some broken
optimization.

Indeed:

[EMAIL PROTECTED]:~$ gcc -O0 -o bla bla.c
[EMAIL PROTECTED]:~$ ./bla
Start of struct 0xeffffc70, content: a=aaaaaaaaaaaaaa rel-pos x=12 offset
o=2
Now we are going to memcpy dst=a+x+o=0xeffffc7e
result of a+x+o access: b=aaaabbbbbbbbbb
Now we are going to bcopy dst=&(tmp_iphdr->saddr)=0xeffffc7e
result of bcopy &(tmp_iphdr->saddr) access: b=aaaabbbbbbbbbb
Now we are going to memcpy dst=&(tmp_iphdr->saddr)=0xeffffc7e
result of memcpy &(tmp_iphdr->saddr) access: b=aaaabbbbbbbbbb
>How-To-Repeat:
        
>Fix:
        


Reply via email to