[Bug c/91667] New: bogus -Wformat-overflow warning

jbeulich at novell dot com gcc-bugzilla@gcc.gnu.org
Thu Sep 5 06:01:00 GMT 2019


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

            Bug ID: 91667
           Summary: bogus -Wformat-overflow warning
           Product: gcc
           Version: 9.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jbeulich at novell dot com
  Target Milestone: ---

Created attachment 46829
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=46829&action=edit
testcase

The attached example causes undue warnings - arrays of <N> chars without nul
terminator ought to not cause such a warning when the format specifier is
%.<N>s.

Observations:
- requires -O1 or higher
- no warning (as expected) on the one printf() after the loop
- warning disappears with one array element removed (loop gets unrolled in this
case)
- warning disappears when un-commenting the commented out array element

For the full original file the issue was noticed with see
https://xenbits.xen.org/gitweb/?p=xen.git;a=blob;f=tools/tests/cpu-policy/test-cpu-policy.c;h=ca3b8dd45fe18fd809804e8ec2e1a7c8d098c3da;hb=refs/heads/staging


More information about the Gcc-bugs mailing list