public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/26118]  New: avr-gcc (GCC) 3.4.5 Bug: copying structure through pointer will destroy the pointer
@ 2006-02-06  9:17 cajus dot hahn at de dot abb dot com
  2006-02-06  9:18 ` [Bug c/26118] " cajus dot hahn at de dot abb dot com
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: cajus dot hahn at de dot abb dot com @ 2006-02-06  9:17 UTC (permalink / raw)
  To: gcc-bugs

there is a bug in avr-gcc (GCC) 3.4.5, that comes with the latest WinAVR
distribution (20060125).
The  avr-gcc (GCC) 3.4.3, that comes with WinAVR 20050214 does NOT contain this
bug. 
The bug exists with and without optimization (I tried -O0 and -Os)
If you try to copy a structure with
 *struct_pointer = struct; 
the struct_pointer gets destroyed.
The assembler code generated seems to add one structure length foreach copied
byte to the pointer.
The complete code is attached. (there I use  *struct_pointer++, but it is the
same problem there).


-- 
           Summary: avr-gcc (GCC) 3.4.5 Bug: copying structure through
                    pointer will destroy the pointer
           Product: gcc
           Version: 3.4.5
            Status: UNCONFIRMED
          Severity: major
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: cajus dot hahn at de dot abb dot com


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


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

* [Bug c/26118] avr-gcc (GCC) 3.4.5 Bug: copying structure through pointer will destroy the pointer
  2006-02-06  9:17 [Bug c/26118] New: avr-gcc (GCC) 3.4.5 Bug: copying structure through pointer will destroy the pointer cajus dot hahn at de dot abb dot com
@ 2006-02-06  9:18 ` cajus dot hahn at de dot abb dot com
  2006-02-06 19:46 ` [Bug target/26118] " lmorrison at nautel dot com
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: cajus dot hahn at de dot abb dot com @ 2006-02-06  9:18 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from cajus dot hahn at de dot abb dot com  2006-02-06 09:18 -------
Created an attachment (id=10783)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=10783&action=view)
Complete project.


-- 


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


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

* [Bug target/26118] avr-gcc (GCC) 3.4.5 Bug: copying structure through pointer will destroy the pointer
  2006-02-06  9:17 [Bug c/26118] New: avr-gcc (GCC) 3.4.5 Bug: copying structure through pointer will destroy the pointer cajus dot hahn at de dot abb dot com
  2006-02-06  9:18 ` [Bug c/26118] " cajus dot hahn at de dot abb dot com
@ 2006-02-06 19:46 ` lmorrison at nautel dot com
  2006-02-06 19:49 ` lmorrison at nautel dot com
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: lmorrison at nautel dot com @ 2006-02-06 19:46 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from lmorrison at nautel dot com  2006-02-06 19:46 -------
Created an attachment (id=10791)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=10791&action=view)
preprocessed source demonstrating bug

produced with commandline:
avr-gcc -E -mmcu=atmega32 -I. -gdwarf-2 -DF_CPU=8000000UL  -Os -funsigned-char
-funsigned-bitfields -fpack-struct -fshort-enums -Wall -Wstrict-prototypes
-Wa,-adhlns=main.lst  -std=gnu99 main.c -o main.i


-- 


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


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

* [Bug target/26118] avr-gcc (GCC) 3.4.5 Bug: copying structure through pointer will destroy the pointer
  2006-02-06  9:17 [Bug c/26118] New: avr-gcc (GCC) 3.4.5 Bug: copying structure through pointer will destroy the pointer cajus dot hahn at de dot abb dot com
  2006-02-06  9:18 ` [Bug c/26118] " cajus dot hahn at de dot abb dot com
  2006-02-06 19:46 ` [Bug target/26118] " lmorrison at nautel dot com
@ 2006-02-06 19:49 ` lmorrison at nautel dot com
  2006-02-06 19:54 ` lmorrison at nautel dot com
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: lmorrison at nautel dot com @ 2006-02-06 19:49 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from lmorrison at nautel dot com  2006-02-06 19:49 -------
Created an attachment (id=10792)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=10792&action=view)
assembly output from previous preprocessed source

Generated with commandline:
avr-gcc -c -mmcu=atmega32 -I. -gdwarf-2 -DF_CPU=8000000UL  -Os -funsigned-char
-funsigned-bitfields -fpack-struct -fshort-enums -Wall -Wstrict-prototypes
-Wa,-adhlns=main.lst  -std=gnu99 -MD -MP -MF .dep/main.o.d main.c -o main.o 

Using gcc 3.4.5 on Win32 host, avr target.


-- 


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


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

* [Bug target/26118] avr-gcc (GCC) 3.4.5 Bug: copying structure through pointer will destroy the pointer
  2006-02-06  9:17 [Bug c/26118] New: avr-gcc (GCC) 3.4.5 Bug: copying structure through pointer will destroy the pointer cajus dot hahn at de dot abb dot com
                   ` (2 preceding siblings ...)
  2006-02-06 19:49 ` lmorrison at nautel dot com
@ 2006-02-06 19:54 ` lmorrison at nautel dot com
  2006-02-06 20:05 ` cajus dot hahn at de dot abb dot com
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: lmorrison at nautel dot com @ 2006-02-06 19:54 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from lmorrison at nautel dot com  2006-02-06 19:54 -------
(From update of attachment 10792)
assembly output from previous preprocessed source

Generated with commandline:
avr-gcc -c -mmcu=atmega32 -I. -gdwarf-2 -DF_CPU=8000000UL  -Os -funsigned-char
-funsigned-bitfields -fpack-struct -fshort-enums -Wall -Wstrict-prototypes
-Wa,-adhlns=main.lst  -std=gnu99 -MD -MP -MF .dep/main.o.d main.c -o main.o 

Using gcc 3.4.5 on Win32 host, avr target.

In the first two examples ( *ptr++ = struct; and memcpy(ptr++, &struct,
sizeof(struct)); ) the source pointer is being incremented by sizeof(struct)
for each byte being copied.

In the third example, the pointer increment is set aside as a distinct
statement.  Here, things behave as expected.


-- 


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


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

* [Bug target/26118] avr-gcc (GCC) 3.4.5 Bug: copying structure through pointer will destroy the pointer
  2006-02-06  9:17 [Bug c/26118] New: avr-gcc (GCC) 3.4.5 Bug: copying structure through pointer will destroy the pointer cajus dot hahn at de dot abb dot com
                   ` (3 preceding siblings ...)
  2006-02-06 19:54 ` lmorrison at nautel dot com
@ 2006-02-06 20:05 ` cajus dot hahn at de dot abb dot com
  2006-03-01 18:53 ` j at uriah dot heep dot sax dot de
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: cajus dot hahn at de dot abb dot com @ 2006-02-06 20:05 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from cajus dot hahn at de dot abb dot com  2006-02-06 20:05 -------
You are right, 
*ptr = struct;
ptr++; 
works.I must have mixed up some of my testing results.
Cajus


-- 


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


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

* [Bug target/26118] avr-gcc (GCC) 3.4.5 Bug: copying structure through pointer will destroy the pointer
  2006-02-06  9:17 [Bug c/26118] New: avr-gcc (GCC) 3.4.5 Bug: copying structure through pointer will destroy the pointer cajus dot hahn at de dot abb dot com
                   ` (4 preceding siblings ...)
  2006-02-06 20:05 ` cajus dot hahn at de dot abb dot com
@ 2006-03-01 18:53 ` j at uriah dot heep dot sax dot de
  2008-12-26 16:12 ` tkoenig at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: j at uriah dot heep dot sax dot de @ 2006-03-01 18:53 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from j at uriah dot heep dot sax dot de  2006-03-01 18:53 -------
After tracking it down, it turns out to be the following change,
introduced between GCC 3.4.3 and 3.4.4:

2005-03-19  Andy Hutchinson  <HutchinsonAndy@netscape.net>

       PR target/18251
       * config/avr/avr.md (movstrhi): Rewrite as RTL loop.
       (*movstrqi_insn): Delete.
       (*movstrhi): Delete.

Here's the corresponding SVN log entry:

Revision 96732 - (view) (download) - [select for diffs]
Modified Sat Mar 19 15:45:41 2005 UTC (11 months, 1 week ago) by marekm
File length: 79688 byte(s)
Diff to previous 96394 (colored)

        PR target/18251
        * config/avr/avr.md (movstrhi): Rewrite as RTL loop.
        (*movstrqi_insn): Delete.
        (*movstrhi): Delete.

When unpatching the diff for that revision, the generated code for the
testcase looks OK again.


-- 

j at uriah dot heep dot sax dot de changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |j at uriah dot heep dot sax
                   |                            |dot de


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


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

* [Bug target/26118] avr-gcc (GCC) 3.4.5 Bug: copying structure through pointer will destroy the pointer
  2006-02-06  9:17 [Bug c/26118] New: avr-gcc (GCC) 3.4.5 Bug: copying structure through pointer will destroy the pointer cajus dot hahn at de dot abb dot com
                   ` (5 preceding siblings ...)
  2006-03-01 18:53 ` j at uriah dot heep dot sax dot de
@ 2008-12-26 16:12 ` tkoenig at gcc dot gnu dot org
  2009-08-20  9:47 ` anitha dot boyapati at atmel dot com
  2009-08-20 22:13 ` eric dot weddington at atmel dot com
  8 siblings, 0 replies; 10+ messages in thread
From: tkoenig at gcc dot gnu dot org @ 2008-12-26 16:12 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from tkoenig at gcc dot gnu dot org  2008-12-26 16:08 -------
Is this still an issue with current trunk?

gcc 3.4 has been out of maintenance for some time.


-- 

tkoenig at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |WAITING


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


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

* [Bug target/26118] avr-gcc (GCC) 3.4.5 Bug: copying structure through pointer will destroy the pointer
  2006-02-06  9:17 [Bug c/26118] New: avr-gcc (GCC) 3.4.5 Bug: copying structure through pointer will destroy the pointer cajus dot hahn at de dot abb dot com
                   ` (6 preceding siblings ...)
  2008-12-26 16:12 ` tkoenig at gcc dot gnu dot org
@ 2009-08-20  9:47 ` anitha dot boyapati at atmel dot com
  2009-08-20 22:13 ` eric dot weddington at atmel dot com
  8 siblings, 0 replies; 10+ messages in thread
From: anitha dot boyapati at atmel dot com @ 2009-08-20  9:47 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from anitha dot boyapati at atmel dot com  2009-08-20 09:46 -------
Created an attachment (id=18403)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=18403&action=view)
Images display the contents of rx_tel_in_ptr before and after the assignment

This issue does not arise with avr-studio 4.17 (win-avr 4.3.2). The memory
contents of rx_tel_in_ptr before assignment and after increment are observed.
The contents of RXtemp got copied to the address pointed by rx_tel_in_ptr as
well as the pointer is post-incremented. Screenshots attached.


-- 


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


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

* [Bug target/26118] avr-gcc (GCC) 3.4.5 Bug: copying structure through pointer will destroy the pointer
  2006-02-06  9:17 [Bug c/26118] New: avr-gcc (GCC) 3.4.5 Bug: copying structure through pointer will destroy the pointer cajus dot hahn at de dot abb dot com
                   ` (7 preceding siblings ...)
  2009-08-20  9:47 ` anitha dot boyapati at atmel dot com
@ 2009-08-20 22:13 ` eric dot weddington at atmel dot com
  8 siblings, 0 replies; 10+ messages in thread
From: eric dot weddington at atmel dot com @ 2009-08-20 22:13 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #9 from eric dot weddington at atmel dot com  2009-08-20 22:13 -------
According to comment #8, the problem no longer exists in gcc 4.3.2. Closing bug
as WONTFIX.


-- 

eric dot weddington at atmel dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|WAITING                     |RESOLVED
      Known to work|                            |4.3.2
         Resolution|                            |WONTFIX


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


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

end of thread, other threads:[~2009-08-20 22:13 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-02-06  9:17 [Bug c/26118] New: avr-gcc (GCC) 3.4.5 Bug: copying structure through pointer will destroy the pointer cajus dot hahn at de dot abb dot com
2006-02-06  9:18 ` [Bug c/26118] " cajus dot hahn at de dot abb dot com
2006-02-06 19:46 ` [Bug target/26118] " lmorrison at nautel dot com
2006-02-06 19:49 ` lmorrison at nautel dot com
2006-02-06 19:54 ` lmorrison at nautel dot com
2006-02-06 20:05 ` cajus dot hahn at de dot abb dot com
2006-03-01 18:53 ` j at uriah dot heep dot sax dot de
2008-12-26 16:12 ` tkoenig at gcc dot gnu dot org
2009-08-20  9:47 ` anitha dot boyapati at atmel dot com
2009-08-20 22:13 ` eric dot weddington at atmel dot com

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).