<html>
<head>
<base href="http://bugs.llvm.org/">
</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-compat check wrongly complains about differing behaviour"
href="http://bugs.llvm.org/show_bug.cgi?id=32595">32595</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>gcc-compat check wrongly complains about differing behaviour
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>4.0
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>All
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>LLVM Codegen
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>royger@freebsd.org
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>Created <span class=""><a href="attachment.cgi?id=18260" name="attach_18260" title="Sample test case">attachment 18260</a> <a href="attachment.cgi?id=18260&action=edit" title="Sample test case">[details]</a></span>
Sample test case
Hello,
The attached code triggers the following clang warning:
test.c:25:16: warning: 'break' is bound to loop, GCC binds it to switch
[-Wgcc-compat]
while (foo(++i)) {
^
test.c:14:9: note: expanded from macro 'foo'
break; \
^
I haven't been able to spot what this different behaviour is, I've compiled the
attached test with clang 3.8, gcc 4.6 and gcc 5.4 and the output is always the
same:
D
i: 1
D
i: 2
D
i: 3
E
END
Also, I'm not sure what clang complains about, I don't think there's any
ambiguity here, and the "break" should apply to the inner switch. Could someone
clarify what's wrong with this, and how this should be fixed?
Note that the attached test.c is a simplification of an issue seen while
building Xen, in which case using a macro makes sense [0][1].
Roger.
[0]
<a href="http://xenbits.xen.org/gitweb/?p=xen.git;a=blob;f=xen/arch/x86/hvm/dm.c;h=d72b7bd8357e9d7f37be4f3ea0d1e6eac1ab4540;hb=refs/heads/staging#l411">http://xenbits.xen.org/gitweb/?p=xen.git;a=blob;f=xen/arch/x86/hvm/dm.c;h=d72b7bd8357e9d7f37be4f3ea0d1e6eac1ab4540;hb=refs/heads/staging#l411</a>
[1]
<a href="http://xenbits.xen.org/gitweb/?p=xen.git;a=blob;f=xen/include/asm-x86/atomic.h;h=2fbe70551898bf4e8a866d9339eaf20d91991f9b;hb=refs/heads/staging#l46">http://xenbits.xen.org/gitweb/?p=xen.git;a=blob;f=xen/include/asm-x86/atomic.h;h=2fbe70551898bf4e8a866d9339eaf20d91991f9b;hb=refs/heads/staging#l46</a></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>