https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108522
Jakub Jelinek <jakub at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jakub at gcc dot gnu.org Priority|P3 |P2 Target Milestone|--- |12.3 --- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> --- At least for backports one option can be punt (give the constant maximum or minimum) when variable length structures are involved, almost nobody uses them (with the exception of Ada but then _FORTIFY_SOURCE=3 isn't on) and they are quite a mess to support. Otherwise, one needs to make sure to use TREE_OPERAND (t, 2) of COMPONENT_REF if non-NULL. On the above testcase one can see: _3 = &s.1_9->b{off: _1}; _12 = __builtin_dynamic_object_size (_3, 1); That {off: _1} in there means COMPONENT_REF's last operand isn't NULL, but is SSA_NAME _1. That contains something that should be used instead of DECL_FIELD_OFFSET if specified, because in DECL_FIELD_OFFSET you'll see a VAR_DECL that contained that value during gimplification, but isn't maintained later on. tree-object-size.cc currently uses byte_position, which is ok if last COMPONENT_REF's operand is NULL, otherwise it should be byte_from_pos (TREE_OPERAND (component_ref, 2), DECL_FIELD_BIT_OFFSET (field)); where field is TREE_OPERAND (component_ref, 1).