<html>
<head>
<base href="https://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 - When declaring variable with __auto_type, name should not be in scope until after initializer"
href="https://bugs.llvm.org/show_bug.cgi?id=35957">35957</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>When declaring variable with __auto_type, name should not be in scope until after initializer
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>5.0
</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>enhancement
</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>oliver.kleinke@c-01a.de
</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=19679" name="attach_19679" title="example program code">attachment 19679</a> <a href="attachment.cgi?id=19679&action=edit" title="example program code">[details]</a></span>
example program code
When declaring a variable with __auto_type and initializing it with a variable
in an outer scope, having the same name, clang fails with
"error: variable 'var' declared with deduced type '__auto_type' cannot appear
in its own initializer"
The GCC docs (<a href="https://gcc.gnu.org/onlinedocs/gcc/Typeof.html">https://gcc.gnu.org/onlinedocs/gcc/Typeof.html</a>, at bottom) state
that "[..]the name of the variable is not in scope until after the
initializer."
Note that GCC behaviour is similar to a variable declaration with a standard
type-specifier. I attach a small example that demonstrates both cases.</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>