<html>
<head>
<base href="https://llvm.org/bugs/" />
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW " title="NEW --- - GCC finds "set but not used" but Clang doesn't" href="https://urldefense.proofpoint.com/v2/url?u=https-3A__llvm.org_bugs_show-5Fbug.cgi-3Fid-3D23725&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=pF93YEPyB-J_PERP4DUZOJDzFVX5ZQ57vQk33wu0vio&m=IZFd95FPpA1pSBIxJwiiT2kSjqVPr_lTy44dEcJAJp0&s=xDTDYKQFA4C7zX_rE2oXgmJP3uYrWM2VUI6H6V1JwGA&e=">23725</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>GCC finds "set but not used" but Clang doesn't
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>unspecified
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>Frontend
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>wkoszek@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvmbugs@cs.uiuc.edu
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>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@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@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@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 <a href="https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_wkoszek_libcla.git&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=pF93YEPyB-J_PERP4DUZOJDzFVX5ZQ57vQk33wu0vio&m=IZFd95FPpA1pSBIxJwiiT2kSjqVPr_lTy44dEcJAJp0&s=8rzY6fP4Y-Ozw3WflGashUAxHw0H0lauL45L4eDEQag&e=">https://github.com/wkoszek/libcla.git</a>
Commit:
<a href="https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_wkoszek_libcla_commit_a4b5afe528ce67daf10e23e838f5643ef5865c0b&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=pF93YEPyB-J_PERP4DUZOJDzFVX5ZQ57vQk33wu0vio&m=IZFd95FPpA1pSBIxJwiiT2kSjqVPr_lTy44dEcJAJp0&s=Z6CdXAdI3USvM2mQZgcKyKPt9MsC9mT480qx9RdTGIw&e=">https://github.com/wkoszek/libcla/commit/a4b5afe528ce67daf10e23e838f5643ef5865c0b</a>
Just comment out line 114 to get the same result.</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>