https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118024
Jakub Jelinek <jakub at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jakub at gcc dot gnu.org --- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> --- Ugh, the for (tree amats = DECL_ATTRIBUTES (alloc_decl), rmats = DECL_ATTRIBUTES (dealloc_decl); (amats = lookup_attribute ("malloc", amats)) || (rmats = lookup_attribute ("malloc", rmats)); amats = amats ? TREE_CHAIN (amats) : NULL_TREE, rmats = rmats ? TREE_CHAIN (rmats) : NULL_TREE) mess. If the first lookup_attribute returns non-NULL, then the second isn't done at all and so rmats will be just some random attribute, not necessarily malloc. Unfortunately the obvious fix --- gimple-ssa-warn-access.cc.jj2 2024-12-07 11:35:49.467439817 +0100 +++ gimple-ssa-warn-access.cc 2024-12-13 11:59:10.056161729 +0100 @@ -1936,11 +1936,12 @@ matching_alloc_calls_p (tree alloc_decl, With AMATS set to the Allocator's Malloc ATtributes, and RMATS set to Reallocator's Malloc ATtributes... */ for (tree amats = DECL_ATTRIBUTES (alloc_decl), - rmats = DECL_ATTRIBUTES (dealloc_decl); - (amats = lookup_attribute ("malloc", amats)) - || (rmats = lookup_attribute ("malloc", rmats)); + rmats = DECL_ATTRIBUTES (dealloc_decl); + ((amats = lookup_attribute ("malloc", amats)), + (rmats = lookup_attribute ("malloc", rmats)), + (amats || rmats)); amats = amats ? TREE_CHAIN (amats) : NULL_TREE, - rmats = rmats ? TREE_CHAIN (rmats) : NULL_TREE) + rmats = rmats ? TREE_CHAIN (rmats) : NULL_TREE) { if (tree args = amats ? TREE_VALUE (amats) : NULL_TREE) if (tree adealloc = TREE_VALUE (args)) regresses FAIL: gcc.dg/Wmismatched-dealloc-2.c (test for excess errors) FAIL: gcc.dg/Wmismatched-dealloc-3.c (test for excess errors)