[Bug c/46635] c-family/c-common.c uses BITS_PER_UNIT in lieu of TYPE_PRECISION (char_type_node)
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=46635 Andrew Pinski changed: What|Removed |Added Last reconfirmed||2024-04-02 Ever confirmed|0 |1 Status|UNCONFIRMED |NEW --- Comment #3 from Andrew Pinski --- 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); ```
[Bug c/46635] c-family/c-common.c uses BITS_PER_UNIT in lieu of TYPE_PRECISION (char_type_node)
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=46635 --- Comment #2 from Eric Gallager --- (In reply to Jorn Wolfgang Rennecke from comment #1) > As Joseph S. Myers bentioned in comment 1 of PR46633, (this is the last bug open blocking that one, btw)
[Bug c/46635] c-family/c-common.c uses BITS_PER_UNIT in lieu of TYPE_PRECISION (char_type_node)
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