<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 --- - False positive Wreturn-type warning"
href="https://llvm.org/bugs/show_bug.cgi?id=25521">25521</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>False positive Wreturn-type warning
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>3.7
</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>yyc1992@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>The following code gives a warning about control flow reaching the end of
function without returning a value even though the function will always reach
the `return 1;` statement and won't reach the end of the function.
```
int f()
{
for (int i = 1;--i >= 0;) {
return 1;
}
}
```
Given no warning about this is given if the loop condition is replaced with `1`
I hope it is also possible for clang to figure out that the loop is executed as
least once and silence the warning.
This (admittedly stupid....) code pattern arise from macro expansion to setup a
single time local context.
Ref GCC bug report <a href="https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68336">https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68336</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>