From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18389 invoked by alias); 5 Nov 2002 16:26:02 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 18370 invoked by uid 71); 5 Nov 2002 16:26:02 -0000 Resent-Date: 5 Nov 2002 16:26:02 -0000 Resent-Message-ID: <20021105162602.18369.qmail@sources.redhat.com> Resent-From: gcc-gnats@gcc.gnu.org (GNATS Filer) Resent-Cc: gcc-prs@gcc.gnu.org, gcc-bugs@gcc.gnu.org Resent-Reply-To: gcc-gnats@gcc.gnu.org, kyle_s_hoyt@raytheon.com Received: (qmail 10618 invoked by uid 61); 5 Nov 2002 16:17:56 -0000 Message-Id: <20021105161756.10617.qmail@sources.redhat.com> Date: Tue, 05 Nov 2002 08:26:00 -0000 From: kyle_s_hoyt@raytheon.com Reply-To: kyle_s_hoyt@raytheon.com To: gcc-gnats@gcc.gnu.org X-Send-Pr-Version: gnatsweb-2.9.3 (1.1.1.1.2.31) Subject: c++/8464: Bus Error (SIGBUS) due to misaligned access X-SW-Source: 2002-11/txt/msg00228.txt.bz2 List-Id: >Number: 8464 >Category: c++ >Synopsis: Bus Error (SIGBUS) due to misaligned access >Confidential: no >Severity: serious >Priority: medium >Responsible: unassigned >State: open >Class: wrong-code >Submitter-Id: net >Arrival-Date: Tue Nov 05 08:26:00 PST 2002 >Closed-Date: >Last-Modified: >Originator: Kyle Hoyt >Release: 2.95.2 19991024 >Organization: >Environment: SunOS 2.6 Generic_108528-06 sun4u sparc SUNW,Ultra-250 >Description: Copying of data from a pointer results in a SIGBUS error. Basically, the compiler is generating a ldd instruction when the data is not guaranteed to be 8-byte aligned. I have tried to multiple options such as the __attribute__ ((aligned)); but I can not get the compiler not to create the ldd instruction. >How-To-Repeat: Compile the included code and run. Basically, this is a real stripped down version of the program. The program receives Navigation Data messages via a data tape. The message is guarranteed to be 4 byte aligned but not 8 byte. The ProcessNav routine stores a history of the navigation data. Thus it copies the message and puts it in a FIFO. The code works on Pentium (G++ complier) and PowerPC (GreenHills compiler) platforms but not on Sparc. >Fix: Change the code to use bcopy. >Release-Note: >Audit-Trail: >Unformatted: ----gnatsweb-attachment---- Content-Type: text/plain; name="gccbug.txt" Content-Disposition: inline; filename="gccbug.txt" typedef struct { int message; int numwords; double latitude; double longitude; double altitude; double ew_rate; double ns_rate; int time; } NAVIGATION_DATAS __attribute__ ((aligned(4))); void ProcessNavData(NAVIGATION_DATAS *nav_ptr) { NAVIGATION_DATAS store; store = *nav_ptr; } int main() { unsigned int data[1024]; ProcessNavData((NAVIGATION_DATAS *)&data[0]); ProcessNavData((NAVIGATION_DATAS *)&data[1]); }