From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23642 invoked by alias); 6 Feb 2006 19:54:40 -0000 Received: (qmail 23624 invoked by uid 48); 6 Feb 2006 19:54:37 -0000 Date: Mon, 06 Feb 2006 19:54:00 -0000 Message-ID: <20060206195437.23623.qmail@sourceware.org> X-Bugzilla-Reason: CC References: Subject: [Bug target/26118] avr-gcc (GCC) 3.4.5 Bug: copying structure through pointer will destroy the pointer In-Reply-To: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "lmorrison at nautel dot com" Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2006-02/txt/msg00549.txt.bz2 List-Id: ------- 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