public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "noring at nocrew dot org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c/98627] New: GCC emits unaligned memory access instructions causing address error exceptions with the 68000 architecture Date: Mon, 11 Jan 2021 17:22:32 +0000 [thread overview] Message-ID: <bug-98627-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98627 Bug ID: 98627 Summary: GCC emits unaligned memory access instructions causing address error exceptions with the 68000 architecture Product: gcc Version: 9.3.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: noring at nocrew dot org Target Milestone: --- The 68000 architecture requires that (16-bit) word and (32-bit) long memory accesses are aligned with even addresses, but GCC frequently emits code that breaks this when compiling with optimisations (O1 or higher). This causes address error exceptions, which are fatal errors that crash programs. For example, consider struct s { char a, b, c, d, e; }; struct s f(char a) { return (struct s) { .a = a, .d = 'd' }; } that GCC with O1 will compile into 00000000 <f>: 0: 2049 moveal %a1,%a0 2: 202f 0004 movel %sp@(4),%d0 6: 42a9 0001 clrl %a1@(1) /* <<<--- unaligned long clear */ a: 1280 moveb %d0,%a1@ c: 137c 0064 0003 moveb #100,%a1@(3) 12: 4e75 rts where offset 6 has "clrl %a1@(1)", which is an unaligned 32-bit long clear. GCC can emit several similar variants of this, for example unaligned 16-bit word clears, and possibly others.
next reply other threads:[~2021-01-11 17:22 UTC|newest] Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-01-11 17:22 noring at nocrew dot org [this message] 2021-01-11 18:04 ` [Bug c/98627] " schwab@linux-m68k.org 2021-01-11 19:12 ` noring at nocrew dot org 2021-01-11 19:24 ` schwab@linux-m68k.org 2021-01-11 20:02 ` noring at nocrew dot org 2021-01-11 20:13 ` schwab@linux-m68k.org 2021-01-11 20:36 ` noring at nocrew dot org 2021-01-11 20:41 ` schwab@linux-m68k.org 2021-01-12 16:26 ` mikpelinux at gmail dot com 2021-01-12 19:20 ` noring at nocrew dot org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-98627-4@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).