public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "kkojima at gcc dot gnu dot org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug middle-end/28160] Bogus "size of array 'foo' is too large" error with -mms-bitfields
Date: Mon, 26 Jun 2006 23:10:00 -0000	[thread overview]
Message-ID: <20060626224237.14689.qmail@sourceware.org> (raw)
In-Reply-To: <bug-28160-5208@http.gcc.gnu.org/bugzilla/>



------- Comment #4 from kkojima at gcc dot gnu dot org  2006-06-26 22:42 -------
Thanks for your comment. Perhaps one solution would be to handle
such bit fields with excessive sizes as the case of "no remaining
bits in alignment".  I'm testing the appended patch which changes
lines you've pointed out.

--- ORIG/trunk/gcc/stor-layout.c        2006-06-13 09:06:36.000000000 +0900
+++ LOCAL/trunk/gcc/stor-layout.c       2006-06-26 16:43:12.000000000 +0900
@@ -1047,17 +1047,20 @@ place_field (record_layout_info rli, tre

              if (rli->remaining_in_alignment < bitsize)
                {
+                 HOST_WIDE_INT typesize = tree_low_cst (TYPE_SIZE (type), 1);
+
                  /* out of bits; bump up to next 'word'.  */
-                 rli->offset = DECL_FIELD_OFFSET (rli->prev_field);
                  rli->bitpos
-                   = size_binop (PLUS_EXPR, TYPE_SIZE (type),
-                                 DECL_FIELD_BIT_OFFSET (rli->prev_field));
+                   = size_binop (PLUS_EXPR, rli->bitpos,
+                                 bitsize_int (rli->remaining_in_alignment));
                  rli->prev_field = field;
-                 rli->remaining_in_alignment
-                   = tree_low_cst (TYPE_SIZE (type), 1);
+                 if (typesize < bitsize)
+                   rli->remaining_in_alignment = 0;
+                 else
+                   rli->remaining_in_alignment = typesize - bitsize;
                }
-
-             rli->remaining_in_alignment -= bitsize;
+             else
+               rli->remaining_in_alignment -= bitsize;
            }
          else
            {
@@ -1119,9 +1121,16 @@ place_field (record_layout_info rli, tre
          if (DECL_SIZE (field) != NULL
              && host_integerp (TYPE_SIZE (TREE_TYPE (field)), 0)
              && host_integerp (DECL_SIZE (field), 0))
-           rli->remaining_in_alignment
-             = tree_low_cst (TYPE_SIZE (TREE_TYPE(field)), 1)
-               - tree_low_cst (DECL_SIZE (field), 1);
+           {
+             HOST_WIDE_INT bitsize = tree_low_cst (DECL_SIZE (field), 1);
+             HOST_WIDE_INT typesize
+               = tree_low_cst (TYPE_SIZE (TREE_TYPE (field)), 1);
+
+             if (typesize < bitsize)
+               rli->remaining_in_alignment = 0;
+             else
+               rli->remaining_in_alignment = typesize - bitsize;
+           }

          /* Now align (conventionally) for the new type.  */
          type_align = TYPE_ALIGN (TREE_TYPE (field));


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28160


  parent reply	other threads:[~2006-06-26 22:42 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-06-25  8:13 [Bug middle-end/28160] New: " kkojima at gcc dot gnu dot org
2006-06-26 20:47 ` [Bug middle-end/28160] " seongbae dot park at gmail dot com
2006-06-26 20:47 ` seongbae dot park at gmail dot com
2006-06-26 21:10 ` seongbae dot park at gmail dot com
2006-06-26 23:10 ` kkojima at gcc dot gnu dot org [this message]
2006-06-29 21:45 ` patchapp at dberlin dot org
2006-07-15  6:59 ` kkojima at gcc dot gnu dot org
2006-07-15 23:12 ` kkojima at gcc dot gnu dot org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20060626224237.14689.qmail@sourceware.org \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).