This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c/47273] New: References to unaligned packed structure members not allowed


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]