https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106782
Bug ID: 106782 Summary: dump_printf_loc has incorrect format attribute Product: gcc Version: 13.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: other Assignee: unassigned at gcc dot gnu.org Reporter: jakub at gcc dot gnu.org Target Milestone: --- We don't perform -Wformat checks on dump_printf_loc calls because it pretends it has a va_list argument instead of ... at the end: --- gcc/dumpfile.h.jj 2022-01-18 11:58:59.501983213 +0100 +++ gcc/dumpfile.h 2022-08-31 10:36:25.789850981 +0200 @@ -574,7 +574,7 @@ extern void dump_printf (const dump_meta extern void dump_printf_loc (const dump_metadata_t &, const dump_user_location_t &, const char *, ...) - ATTRIBUTE_GCC_DUMP_PRINTF (3, 0); + ATTRIBUTE_GCC_DUMP_PRINTF (3, 4); extern void dump_function (int phase, tree fn); extern void dump_basic_block (dump_flags_t, basic_block, int); extern void dump_generic_expr_loc (const dump_metadata_t &, Unfortunately this patch results in tons of warnings that should be fixed one way or another. E.g.: ../../gcc/tree-vect-slp.cc: In function ‘void vect_print_slp_tree(dump_flags_t, dump_location_t, slp_tree)’: ../../gcc/tree-vect-slp.cc:2528:49: warning: format ‘%p’ expects argument of type ‘void*’, but argument 5 has type ‘slp_tree’ {aka ‘_slp_tree*’} [-Wformat=] 2528 | dump_printf_loc (metadata, user_loc, "node%s %p (max_nunits=%u, refcnt=%u)", | ~^ | | | void* ...... 2533 | : ""), node, | ~~~~ | | | slp_tree {aka _slp_tree*} ../../gcc/tree-vect-slp.cc:2528:64: warning: format ‘%u’ expects argument of type ‘unsigned int’, but argument 6 has type ‘long int’ [-Wformat=] 2528 | dump_printf_loc (metadata, user_loc, "node%s %p (max_nunits=%u, refcnt=%u)", | ~^ | | | unsigned int | %lu ...... 2534 | estimated_poly_value (node->max_nunits), | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | | | long int