http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56977

             Bug #: 56977
           Summary: gcc -Og incorrectly warns about 'constant zero length
                    parameter'
    Classification: Unclassified
           Product: gcc
           Version: 4.8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassig...@gcc.gnu.org
        ReportedBy: bauge...@cisco.com


Created attachment 29881
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=29881
Preprocessed version of snippet in the Description field.

Compiling this tiny snippet with the command 'gcc -v -Og' produces an incorrect
warning about zero length parameter:

#include <string.h>

void foo(char *buf, size_t w, size_t h)
{
    size_t n = w * h;
    if (n > 0)
        memset(buf, 123, n);
}

The warning looks like this:
/usr/include/bits/string3.h:81:30: warning: call to ‘__warn_memset_zero_len’
declared with attribute warning: memset used with constant zero length
parameter; this could be due to transposed parameters [enabled by default]
       __warn_memset_zero_len ();


Output from gcc -v:
$ gcc -v
Using built-in specs.
COLLECT_GCC=/usr/x86_64-pc-linux-gnu/gcc-bin/4.8.0/gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-pc-linux-gnu/4.8.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /var/tmp/portage/sys-devel/gcc-4.8.0/work/gcc-4.8.0/configure
--prefix=/usr --bindir=/usr/x86_64-pc-linux-gnu/gcc-bin/4.8.0
--includedir=/usr/lib/gcc/x86_64-pc-linux-gnu/4.8.0/include
--datadir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.8.0
--mandir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.8.0/man
--infodir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.8.0/info
--with-gxx-include-dir=/usr/lib/gcc/x86_64-pc-linux-gnu/4.8.0/include/g++-v4
--host=x86_64-pc-linux-gnu --build=x86_64-pc-linux-gnu --disable-altivec
--disable-fixed-point --without-ppl --without-cloog --enable-lto --enable-nls
--without-included-gettext --with-system-zlib --enable-obsolete
--disable-werror --enable-secureplt --enable-multilib
--with-multilib-list=m32,m64 --enable-libmudflap --disable-libssp
--enable-libgomp
--with-python-dir=/share/gcc-data/x86_64-pc-linux-gnu/4.8.0/python
--enable-checking=release --disable-libgcj --enable-libstdcxx-time
--disable-libquadmath --enable-languages=c,c++,objc --enable-shared
--enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu
--enable-targets=all --with-bugurl=http://bugs.gentoo.org/
--with-pkgversion='Gentoo 4.8.0 p1.1, pie-0.5.5'
Thread model: posix
gcc version 4.8.0 (Gentoo 4.8.0 p1.1, pie-0.5.5)

Reply via email to