<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 --- - Clang doesn't like 'void inline'. Regression wrt. gcc" href="https://urldefense.proofpoint.com/v2/url?u=https-3A__llvm.org_bugs_show-5Fbug.cgi-3Fid-3D23916&d=AwMBaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=pF93YEPyB-J_PERP4DUZOJDzFVX5ZQ57vQk33wu0vio&m=SmlkmAo8UzlqJlSCoyVrwvIrAULHLZA3cYrZ9t8_aBA&s=3Acf_r9WjUWXTdBjKqLZvJAbF7_orBRXbAcwr1JKkxE&e=">23916</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Clang doesn't like 'void inline'. Regression wrt. gcc
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>3.6
</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>Created <span class=""><a href="attachment.cgi?id=14504" name="attach_14504" title="Sample.c code mentioned in the bug case">attachment 14504</a> <a href="attachment.cgi?id=14504&action=edit" title="Sample.c code mentioned in the bug case">[details]</a></span>
Sample.c code mentioned in the bug case
Our codebase used 'void inline' variable, and it seems like Clang doesn't like
it.
----------------------- sample.c ---------------------------------
#include <stdio.h>
#ifdef FIX
#define PREFIX static
#else
#define PREFIX
#endif
struct stats {
int pkt;
};
typedef struct stats stats_t;
PREFIX void inline
recv_stats(stats_t* stats, void *p)
{
stats->pkt++;
}
int
main()
{
stats_t stats;
recv_stats(&stats, 0);
}
--------------------------------------------------------------------
vm:~/vr/accelerator% 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)
vm:~/vr/accelerator% cc sample.c -o sample
vm:~/vr/accelerator% cc -DFIX sample.c -o sample.fix
vm:~/vr/accelerator% ls -la sample sample.fix
-rwxrwxr-x 1 wkoszek wkoszek 8497 Jun 22 16:10 sample
-rwxrwxr-x 1 wkoszek wkoszek 8497 Jun 22 16:10 sample.fix
vm:~/vr/accelerator% clang sample.c -o sample
/tmp/sample-b5c729.o: In function `main':
sample.c:(.text+0x17): undefined reference to `recv_stats'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
vm:~/vr/accelerator% clang -DFIX sample.c -o sample
This leads to:
vm:~/vr/accelerator% cc -c -o sample-cc.o sample.c
vm:~/vr/accelerator% clang -c -o sample-clang.o sample.c
vm:~/vr/accelerator% nm sample-cc.o
000000000000001d T main
0000000000000000 T recv_stats
vm:~/vr/accelerator% nm sample-clang.o
0000000000000000 T main
U recv_stats
Conclusion:
if a function is "void inline", GCC compiled the function OK and put it in the
.text section. Clang compiles the code OK, but puts the code in unknown
section.</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>