<html>
<head>
<base href="http://llvm.org/bugs/" />
</head>
<body><span class="vcard"><a class="email" href="mailto:jonathan.sauer@gmx.de" title="jonathan.sauer@gmx.de">jonathan.sauer@gmx.de</a>
</span> changed
<a class="bz_bug_link
bz_status_RESOLVED bz_closed"
title="RESOLVED WORKSFORME - clang: Re-declaration of a local variable inside a for-loop is allowed"
href="http://llvm.org/bugs/show_bug.cgi?id=18787">bug 18787</a>
<br>
<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>What</th>
<th>Removed</th>
<th>Added</th>
</tr>
<tr>
<td style="text-align:right;">Status</td>
<td>NEW
</td>
<td>RESOLVED
</td>
</tr>
<tr>
<td style="text-align:right;">CC</td>
<td>
</td>
<td>jonathan.sauer@gmx.de
</td>
</tr>
<tr>
<td style="text-align:right;">Resolution</td>
<td>---
</td>
<td>WORKSFORME
</td>
</tr></table>
<p>
<div>
<b><a class="bz_bug_link
bz_status_RESOLVED bz_closed"
title="RESOLVED WORKSFORME - clang: Re-declaration of a local variable inside a for-loop is allowed"
href="http://llvm.org/bugs/show_bug.cgi?id=18787#c4">Comment # 4</a>
on <a class="bz_bug_link
bz_status_RESOLVED bz_closed"
title="RESOLVED WORKSFORME - clang: Re-declaration of a local variable inside a for-loop is allowed"
href="http://llvm.org/bugs/show_bug.cgi?id=18787">bug 18787</a>
from <span class="vcard"><a class="email" href="mailto:jonathan.sauer@gmx.de" title="jonathan.sauer@gmx.de">jonathan.sauer@gmx.de</a>
</span></b>
<pre>gcc 4.2.1 doesn't complain when specifying C99 as the standard (-std=c99). In
C89 (-std=c89) it (correctly) complains about "redeclaration of āiā with no
linkage", because in C89 the definitions in the first clause of a for statement
are in the surrounding scope instead of the loop body's scope.
clang also complains when using C89:
% ~/LLVM/build/Release+Asserts/bin/clang -std=c89 clang.c
clang.c:5:14: error: redefinition of 'i'
for (int i = 0; i < 100; ++i) { }
^
clang.c:3:9: note: previous definition is here
int i;
^
1 error generated.
I guess gcc and clang use different C standards as default, which is why you
got the differing results.</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>