<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 --- - an impossible case for -Wimplicit-fallthrough and [[clang::fallthrough]]"
href="https://llvm.org/bugs/show_bug.cgi?id=30636">30636</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>an impossible case for -Wimplicit-fallthrough and [[clang::fallthrough]]
</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>C++
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>aduret@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>dgregor@apple.com, llvm-bugs@lists.llvm.org
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>Here is a function that I have reduced from some real-life code that I am
unable to compile with -Wimplicit-fallthrough.
% cat foo.cc
template<bool param>
int fun(int i)
{
switch (i)
{
case 1:
if (param)
return 3;
// [[clang::fallthrough]];
case 2:
return 4;
default:
return 5;
}
}
template int fun<true>(int);
template int fun<false>(int);
% clang++-3.9 -std=c++11 -Wimplicit-fallthrough foo.cc -cfoo.cc:10:5: warning:
unannotated fall-through between switch labels [-Wimplicit-fallthrough]
case 2:
^
foo.cc:18:14: note: in instantiation of function template specialization
'fun<false>' requested here
template int fun<false>(int);
^
foo.cc:10:5: note: insert '[[clang::fallthrough]];' to silence this warning
[...]
Unfortunately, inserting [[clang::fallthrough]] gives a different error:
% clang++-3.9 -std=c++11 -Wimplicit-fallthrough foo.cc -c
foo.cc:9:7: warning: fallthrough annotation in unreachable code
[-Wimplicit-fallthrough]
[[clang::fallthrough]];
^
foo.cc:17:14: note: in instantiation of function template specialization
'fun<true>' requested here
template int fun<true>(int);
^
1 warning generated.</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>