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: unassig...@gcc.gnu.org
        ReportedBy: waldemarbancew...@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.

Reply via email to