This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug middle-end/45819] [4.5 Regression] unexpected unaligned access to volatile int
- From: "rguenth at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 22 Jul 2011 12:25:20 +0000
- Subject: [Bug middle-end/45819] [4.5 Regression] unexpected unaligned access to volatile int
- Auto-submitted: auto-generated
- References: <bug-45819-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45819
Richard Guenther <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |INVALID
--- Comment #15 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-07-22 12:25:01 UTC ---
struct ehci_regs {
char x;
unsigned int port_status[0];
} __attribute__ ((packed));
//} __attribute__ ((packed,aligned(__alignof__(int))));
struct ehci_hcd{
struct ehci_regs *regs;
};
int ehci_hub_control (
struct ehci_hcd *ehci,
int wIndex
) {
unsigned int *status_reg = &ehci->regs->port_status[wIndex];
return *(volatile unsigned int *)status_reg;
}
this one is invalid as well, with or without the aligned attribute.
ehci->regs->port_status[wIndex] _is_ unaligned. I don't think there
is currently a way to tell GCC that the struct layout of ehci_regs is
packed but port_status is properly aligned to the natural alignment of int.