public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/46635] New: c-family/c-common.c uses BITS_PER_UNIT in lieu of TYPE_PRECISION (char_type_node)
@ 2010-11-24  6:59 amylaar at gcc dot gnu.org
  2010-11-24 16:09 ` [Bug c/46635] " amylaar at gcc dot gnu.org
  2024-04-02 22:21 ` pinskia at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: amylaar at gcc dot gnu.org @ 2010-11-24  6:59 UTC (permalink / raw)
  To: gcc-bugs

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

           Summary: c-family/c-common.c uses BITS_PER_UNIT in lieu of
                    TYPE_PRECISION (char_type_node)
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: amylaar@gcc.gnu.org
            Blocks: 46633


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug c/46635] c-family/c-common.c uses BITS_PER_UNIT in lieu of TYPE_PRECISION (char_type_node)
  2010-11-24  6:59 [Bug c/46635] New: c-family/c-common.c uses BITS_PER_UNIT in lieu of TYPE_PRECISION (char_type_node) amylaar at gcc dot gnu.org
@ 2010-11-24 16:09 ` amylaar at gcc dot gnu.org
  2024-04-02 22:21 ` pinskia at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: amylaar at gcc dot gnu.org @ 2010-11-24 16:09 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Jorn Wolfgang Rennecke <amylaar at gcc dot gnu.org> 2010-11-24 15:49:22 UTC ---
As Joseph S. Myers bentioned in comment 1 of PR46633, if
TREE_STRING_LENGTH is considered to be measured in BITS_PER_UNIT
rather than TYPE_PRECISION (char_type_node), fix_string_type actually
has one BITS_PER_UNIT uses too few rather than three to many.

The only other place I came up with in c-common also requires even more
BITS_PER_UNIT:

@@ -8541,8 +8544,14 @@ fold_offsetof_1 (tree expr, tree stop_re
 tree
 fold_offsetof (tree expr, tree stop_ref)
 {
+  tree size = fold_offsetof_1 (expr, stop_ref);
+
+  /* Convert in case a char is more than one unit.  */
+  size
+    = size_binop (CEIL_DIV_EXPR, size,
+                 size_int (TYPE_PRECISION (char_type_node) / BITS_PER_UNIT));
   /* Convert back from the internal sizetype to size_t.  */
-  return convert (size_type_node, fold_offsetof_1 (expr, stop_ref));
+  return convert (size_type_node, size);
 }

 /* Warn for A ?: C expressions (with B omitted) where A is a boolean


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug c/46635] c-family/c-common.c uses BITS_PER_UNIT in lieu of TYPE_PRECISION (char_type_node)
  2010-11-24  6:59 [Bug c/46635] New: c-family/c-common.c uses BITS_PER_UNIT in lieu of TYPE_PRECISION (char_type_node) amylaar at gcc dot gnu.org
  2010-11-24 16:09 ` [Bug c/46635] " amylaar at gcc dot gnu.org
@ 2024-04-02 22:21 ` pinskia at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-04-02 22:21 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=46635

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2024-04-02
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Confirmed.

in fold_offsetof, we still have:
```
    case COMPONENT_REF:
...
      off = size_binop_loc (input_location, PLUS_EXPR, DECL_FIELD_OFFSET (t),
                            size_int (tree_to_uhwi (DECL_FIELD_BIT_OFFSET (t))
                                      / BITS_PER_UNIT));

```

and:
```
    case ARRAY_REF:
...
      off = size_binop (MULT_EXPR, TYPE_SIZE_UNIT (TREE_TYPE (expr)), t);
```

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-04-02 22:21 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-11-24  6:59 [Bug c/46635] New: c-family/c-common.c uses BITS_PER_UNIT in lieu of TYPE_PRECISION (char_type_node) amylaar at gcc dot gnu.org
2010-11-24 16:09 ` [Bug c/46635] " amylaar at gcc dot gnu.org
2024-04-02 22:21 ` pinskia at gcc dot gnu.org

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).