[LLVMbugs] [Bug 23725] New: GCC finds "set but not used" but Clang doesn't

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Mon Jun 1 22:45:40 PDT 2015


https://llvm.org/bugs/show_bug.cgi?id=23725

            Bug ID: 23725
           Summary: GCC finds "set but not used" but Clang doesn't
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Frontend
          Assignee: unassignedclangbugs at nondot.org
          Reporter: wkoszek at gmail.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Host machine (OSX):

wk% clang -v
Apple LLVM version 6.1.0 (clang-602.0.53) (based on LLVM 3.6.0svn)
Target: x86_64-apple-darwin14.3.0
Thread model: posix

Vagrant VM with Ubuntu ubuntu/trusty64:

vagrant at vagrant-ubuntu-trusty-64:/vagrant/unix/samples$ cc -v
Using built-in specs.
COLLECT_GCC=cc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.8/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 4.8.2-19ubuntu1'
--with-bugurl=file:///usr/share/doc/gcc-4.8/README.Bugs
--enable-languages=c,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr
--program-suffix=-4.8 --enable-shared --enable-linker-build-id
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--with-gxx-include-dir=/usr/include/c++/4.8 --libdir=/usr/lib --enable-nls
--with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug
--enable-libstdcxx-time=yes --enable-gnu-unique-object --disable-libmudflap
--enable-plugin --with-system-zlib --disable-browser-plugin
--enable-java-awt=gtk --enable-gtk-cairo
--with-java-home=/usr/lib/jvm/java-1.5.0-gcj-4.8-amd64/jre --enable-java-home
--with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-4.8-amd64
--with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-4.8-amd64
--with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar
--enable-objc-gc --enable-multiarch --disable-werror --with-arch-32=i686
--with-abi=m64 --with-multilib-list=m32,m64,mx32 --with-tune=generic
--enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu
--target=x86_64-linux-gnu
Thread model: posix
gcc version 4.8.2 (Ubuntu 4.8.2-19ubuntu1)

With GCC:

vagrant at vagrant-ubuntu-trusty-64:/vagrant/unix/samples$ make
cc -g -ggdb -O2 -Wall -pedantic -std=c99 -I../../samples -I../.. -o sample_0
../../samples/sample_0.c ../../cla.c
cc -g -ggdb -O2 -Wall -pedantic -std=c99 -I../../samples -I../.. -o sample_1
../../samples/sample_1.c ../../cla.c
cc -g -ggdb -O2 -Wall -pedantic -std=c99 -I../../samples -I../.. -o sample_2
../../samples/sample_2.c ../../cla.c
cc -g -ggdb -O2 -Wall -pedantic -std=c99 -I../../samples -I../.. -o sample_3
../../samples/sample_3.c ../../cla.c
cc -g -ggdb -O2 -Wall -pedantic -std=c99 -I../../samples -I../.. -o sample_4
../../samples/sample_4.c ../../cla.c
../../samples/sample_4.c: In function ‘nf_cmdlist_build’:
../../samples/sample_4.c:84:14: warning: variable ‘reg_list’ set but not used
[-Wunused-but-set-variable]
  struct cla *reg_list;
              ^
cc -g -ggdb -O2 -Wall -pedantic -std=c99 -I../../samples -I../.. -o sample_5
../../samples/sample_5.c ../../cla.c
vagrant at vagrant-ubuntu-trusty-64:/vagrant/unix/samples$ vim ../^C

Clang doesn't give me any warning. It can't figure out that reg_list isn't
used.

Code:

git clone https://github.com/wkoszek/libcla.git

Commit:

https://github.com/wkoszek/libcla/commit/a4b5afe528ce67daf10e23e838f5643ef5865c0b

Just comment out line 114 to get the same result.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20150602/0fd6defc/attachment.html>


More information about the llvm-bugs mailing list