PR71175 reports two printf-style format/argument mismatches in the arm
backend, found by static analysis:

- arm_elf_asm_cdtor prints the int PRIORITY argument with %.5u; cast it
  to unsigned int to match the format (constructor priorities are
  restricted to [0, 65535] by the front ends, so the value is
  unchanged).
- arm_unwind_emit_sequence prints the unsigned PADFIRST with %d; print
  it with %u instead.

No change in generated code.

gcc/ChangeLog:

        PR target/71175
        * config/arm/arm.cc (arm_elf_asm_cdtor): Cast priority to
        unsigned int to match the %.5u format.
        (arm_unwind_emit_sequence): Print unsigned padfirst with %u
        rather than %d.

Signed-off-by: Dominic P <[email protected]>
---
 gcc/config/arm/arm.cc | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/gcc/config/arm/arm.cc b/gcc/config/arm/arm.cc
index 0bc66abe2..ad98ab7e1 100644
--- a/gcc/config/arm/arm.cc
+++ b/gcc/config/arm/arm.cc
@@ -25300,7 +25300,7 @@ arm_elf_asm_cdtor (rtx symbol, int priority, bool 
is_ctor)
       char buf[18];
       sprintf (buf, "%s.%.5u",
               is_ctor ? ".init_array" : ".fini_array",
-              priority);
+              (unsigned int) priority);
       s = get_section (buf, SECTION_WRITE | SECTION_NOTYPE, NULL_TREE);
     }
   else if (is_ctor)
@@ -30245,7 +30245,7 @@ arm_unwind_emit_sequence (FILE * out_file, rtx p)
     }
   fprintf (out_file, "}\n");
   if (padfirst)
-    fprintf (out_file, "\t.pad #%d\n", padfirst);
+    fprintf (out_file, "\t.pad #%u\n", padfirst);
 }
 
 /*  Emit unwind directives for a SET.  */
-- 
2.55.0

Reply via email to