[Bug c/50569] New: Wrong code error: memcpy eliminated when it is needed
pkoning at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Thu Sep 29 18:58:00 GMT 2011
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50569
Bug #: 50569
Summary: Wrong code error: memcpy eliminated when it is needed
Classification: Unclassified
Product: gcc
Version: 4.6.1
Status: UNCONFIRMED
Severity: major
Priority: P3
Component: c
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: pkoning@gcc.gnu.org
Created attachment 25382
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=25382
Test code that shows the issue
This issue shows up in 4.6.1 but is not present in 4.5.1.
The attached sample code picks up a buffer pointer from external data
structures, copies a block of data to a temporary variable, and then references
the temporary. GCC 4.6.1 optimized away the memcpy and instead directly
references the original data, which is fine... except that the pointer is "char
*" meaning that the data structure in that buffer is not necessarily aligned.
And the references through that pointer are written as if the data IS aligned,
so on my strict-alignment target (MIPS) I get an alignment exception.
GCC 4.5.1 does it right -- it also optimizes away the memcpy but it accesses
the original data using unaligned accesses.
More information about the Gcc-bugs
mailing list