Commit: bb7747e7caee59a8c98cd7d9abc9cd1e9b0e0762 Author: Sergey Sharybin Date: Tue Aug 2 11:10:40 2022 +0200 Branches: master https://developer.blender.org/rBbb7747e7caee59a8c98cd7d9abc9cd1e9b0e0762
Fix undefined behavior in dependency graph tagging The tagging code was iterating over bits set in the ID_RECALC_ALL and was casting the flag to IDRecalcFlag. This was triggering an undefined behavior warning in Clang since the bit might not have a corresponding value in the enumerator. The solution is to pre-define all reacalc flags for all bits. While this seems a bit annoying this seems to be the least fragile solution from all suggested ones. Differential Revision: https://developer.blender.org/D15602 =================================================================== M source/blender/depsgraph/intern/depsgraph_tag.cc M source/blender/makesdna/DNA_ID.h =================================================================== diff --git a/source/blender/depsgraph/intern/depsgraph_tag.cc b/source/blender/depsgraph/intern/depsgraph_tag.cc index 7a2904e3766..d95e871d6c7 100644 --- a/source/blender/depsgraph/intern/depsgraph_tag.cc +++ b/source/blender/depsgraph/intern/depsgraph_tag.cc @@ -220,6 +220,15 @@ void depsgraph_tag_to_component_opcode(const ID *id, *component_type = NodeType::NTREE_OUTPUT; *operation_code = OperationCode::NTREE_OUTPUT; break; + + case ID_RECALC_PROVISION_26: + case ID_RECALC_PROVISION_27: + case ID_RECALC_PROVISION_28: + case ID_RECALC_PROVISION_29: + case ID_RECALC_PROVISION_30: + case ID_RECALC_PROVISION_31: + BLI_assert_msg(0, "Should not happen"); + break; } } @@ -741,6 +750,15 @@ const char *DEG_update_tag_as_string(IDRecalcFlag flag) return "TAG_FOR_UNDO"; case ID_RECALC_NTREE_OUTPUT: return "ID_RECALC_NTREE_OUTPUT"; + + case ID_RECALC_PROVISION_26: + case ID_RECALC_PROVISION_27: + case ID_RECALC_PROVISION_28: + case ID_RECALC_PROVISION_29: + case ID_RECALC_PROVISION_30: + case ID_RECALC_PROVISION_31: + BLI_assert_msg(0, "Should not happen"); + return nullptr; } return nullptr; } diff --git a/source/blender/makesdna/DNA_ID.h b/source/blender/makesdna/DNA_ID.h index 8b99345e237..7ba2b426fcf 100644 --- a/source/blender/makesdna/DNA_ID.h +++ b/source/blender/makesdna/DNA_ID.h @@ -870,6 +870,17 @@ typedef enum IDRecalcFlag : unsigned int { /* The node tree has changed in a way that affects its output nodes. */ ID_RECALC_NTREE_OUTPUT = (1 << 25), + /* Provisioned flags. + * + * Not for actual use. The idea of them is to have all bits of the `IDRecalcFlag` defined to a + * known value, silencing sanitizer warnings when checkign bits of the ID_RECALC_ALL. */ + ID_RECALC_PROVISION_26 = (1 << 26), + ID_RECALC_PROVISION_27 = (1 << 27), + ID_RECALC_PROVISION_28 = (1 << 28), + ID_RECALC_PROVISION_29 = (1 << 29), + ID_RECALC_PROVISION_30 = (1 << 30), + ID_RECALC_PROVISION_31 = (1u << 31), + /*************************************************************************** * Pseudonyms, to have more semantic meaning in the actual code without * using too much low-level and implementation specific tags. */ _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs