This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/47273] New: References to unaligned packed structure members not allowed
- From: "waldemarbancewicz at ruggedcom dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 12 Jan 2011 22:38:44 +0000
- Subject: [Bug c/47273] New: References to unaligned packed structure members not allowed
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47273
Summary: References to unaligned packed structure members not
allowed
Product: gcc
Version: 4.4.5
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: waldemarbancewicz@ruggedcom.com
It would be really nice to have a gcc option that allows references to packed
structure members. Many people in the embedded world work with processors, such
as coldfire and powerpc, that don't show a performance improvement by
performing reference-to-packed-struct-member optimizations. The real problem is
that a lot of legacy code makes use of references to unaligned structure
members and it is a tremendous waste to go and modify all the lines with an
explicit cast when a simple compiler option would do the trick.
The patch to disable the error is one line (in call.c):
static conversion *
reference_binding (tree rto, tree rfrom, tree expr, int flags) {
...
if (TREE_CODE (from) == REFERENCE_TYPE)
{
/* Anything with reference type is an lvalue. */
lvalue_p = clk_ordinary;
from = TREE_TYPE (from);
}
else if (expr)
/*lvalue_p = real_lvalue_p (expr);*/
{ /* Andreas patch */
lvalue_p = real_lvalue_p (expr);
lvalue_p &= ~clk_packed;
}
...
}
However due to my limited knowledge of gcc internals I am not sure this patch
is really correct. Comments would be greatly appreciated.