https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89161

Martin Sebor <msebor at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to fail|10.0                        |10.3.0, 11.2.0, 12.0
   Last reconfirmed|2020-05-01 00:00:00         |2022-1-19

--- Comment #5 from Martin Sebor <msebor at gcc dot gnu.org> ---
GCC 12 or 11 don't warn on the test case in comment #3 but reconfirming the
warning for the test case in comment #0 with GCC 12:

$ gcc -O2 -S -Wall  -fdump-tree-strlen=/dev/stdout pr89161.c 

;; Function main (main, funcdef_no=12, decl_uid=2421, cgraph_uid=13,
symbol_order=13) (executed once)

...
pr89161.c:7: sprintf: objsize = 3, fmtstr = ".%1u"
  Directive 1 at offset 0: ".", length = 1
    Result: 1, 1, 1, 1 (1, 1, 1, 1)
  Directive 2 at offset 1: "%1u"
pr89161.c: In function ‘main’:
pr89161.c:7:24: warning: ‘%1u’ directive writing between 1 and 6 bytes into a
region of size 2 [-Wformat-overflow=]
    7 |         sprintf(buf, ".%1u", (10 * a[0]) / a[1]);
      |                        ^~~
In function ‘print’,
    inlined from ‘main’ at pr89161.c:17:5:
pr89161.c:7:22: note: directive argument in the range [0, 327670]
    7 |         sprintf(buf, ".%1u", (10 * a[0]) / a[1]);
      |                      ^~~~~~
    Result: 1, 6, 6, 6 (2, 7, 7, 7)
  Directive 3 at offset 4: "", length = 1
pr89161.c:7:9: note: ‘sprintf’ output between 3 and 8 bytes into a destination
of size 3
    7 |         sprintf(buf, ".%1u", (10 * a[0]) / a[1]);
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Reply via email to