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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |ASSIGNED
   Last reconfirmed|                            |2016-09-22
           Assignee|unassigned at gcc dot gnu.org      |msebor at gcc dot 
gnu.org
     Ever confirmed|0                           |1

--- Comment #1 from Martin Sebor <msebor at gcc dot gnu.org> ---
The output with the latest patch
(https://gcc.gnu.org/ml/gcc-patches/2016-09/msg01477.html) I see the warnings
below, but only with -Wformat-length=2.

If I understand correctly, you're wondering if (or implying that) there should
be just one warning in each compiler invocation, regardless of the optimization
level.  It seems reasonable in this case but I confess I don't know if it's
possible.  The pass relies on optimization for constant propagation and value
range propagation, and those in turn depend on inlining.  With more function
calls inlined it's possible for the same sprintf call to be duplicated in more
callers and result in more warnings than otherwise.  Maybe there's a way to set
TREE_NO_WARNING for the call statement after it has been diagnosed.  Let me
look into it.

 (set -x; for o in 0 1 2 3; do /build/gcc-77676/gcc/xgcc -B
/build/gcc-77676/gcc -O$o -S -Wformat-length=2  ~/tmp/algapi.i; done)
+ for o in 0 1 2 3
+ /build/gcc-77676/gcc/xgcc -B /build/gcc-77676/gcc -O0 -S -Wformat-length=2
/home/msebor/tmp/algapi.i
crypto/algapi.c: In function ‘crypto_inst_setname’:
crypto/algapi.c:817:6: warning: ‘%s’ directive output may be truncated writing
between 1 and 63 bytes into a region of size 62 [-Wformat-length=]
crypto/algapi.c:817:6: note: format output between 5 and 67 bytes into a
destination of size 64
+ for o in 0 1 2 3
+ /build/gcc-77676/gcc/xgcc -B /build/gcc-77676/gcc -O1 -S -Wformat-length=2
/home/msebor/tmp/algapi.i
crypto/algapi.c: In function ‘crypto_inst_setname’:
crypto/algapi.c:817:6: warning: ‘%s’ directive output may be truncated writing
between 1 and 63 bytes into a region of size 62 [-Wformat-length=]
crypto/algapi.c:817:6: note: format output between 5 and 67 bytes into a
destination of size 64
+ for o in 0 1 2 3
+ /build/gcc-77676/gcc/xgcc -B /build/gcc-77676/gcc -O2 -S -Wformat-length=2
/home/msebor/tmp/algapi.i
crypto/algapi.c: In function ‘crypto_inst_setname’:
crypto/algapi.c:817:6: warning: ‘%s’ directive output may be truncated writing
between 1 and 63 bytes into a region of size 62 [-Wformat-length=]
crypto/algapi.c:817:6: note: format output between 5 and 67 bytes into a
destination of size 64
crypto/algapi.c: In function ‘crypto_alloc_instance2’:
crypto/algapi.c:817:6: warning: ‘%s’ directive output may be truncated writing
between 1 and 63 bytes into a region of size 62 [-Wformat-length=]
crypto/algapi.c:817:6: note: format output between 5 and 67 bytes into a
destination of size 64
+ for o in 0 1 2 3
+ /build/gcc-77676/gcc/xgcc -B /build/gcc-77676/gcc -O3 -S -Wformat-length=2
/home/msebor/tmp/algapi.i
crypto/algapi.c: In function ‘crypto_inst_setname’:
crypto/algapi.c:817:6: warning: ‘%s’ directive output may be truncated writing
between 1 and 63 bytes into a region of size 62 [-Wformat-length=]
crypto/algapi.c:817:6: note: format output between 5 and 67 bytes into a
destination of size 64
crypto/algapi.c: In function ‘crypto_alloc_instance2’:
crypto/algapi.c:817:6: warning: ‘%s’ directive output may be truncated writing
between 1 and 63 bytes into a region of size 62 [-Wformat-length=]
crypto/algapi.c:817:6: note: format output between 5 and 67 bytes into a
destination of size 64
crypto/algapi.c: In function ‘crypto_alloc_instance’:
crypto/algapi.c:817:6: warning: ‘%s’ directive output may be truncated writing
between 1 and 63 bytes into a region of size 62 [-Wformat-length=]
crypto/algapi.c:817:6: note: format output between 5 and 67 bytes into a
destination of size 64

Reply via email to