<html>
<head>
<base href="http://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 --- - Parse error after a cast of a variable with the same name as an existing struct in a ternary operator"
href="http://llvm.org/bugs/show_bug.cgi?id=19748">19748</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Parse error after a cast of a variable with the same name as an existing struct in a ternary operator
</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>Windows NT
</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>vz-llvm@zeitlins.org
</td>
</tr>
<tr>
<th>CC</th>
<td>dgregor@apple.com, llvmbugs@cs.uiuc.edu
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>Consider this:
% cat clang_tm.cpp
struct tm { };
int main()
{
int tm = 1;
const int nothing = 0;
return tm ? (const int)tm : nothing;
}
% clang++ -c -Wall clang_tm.cpp
clang_tm.cpp:7:31: error: unexpected ':' in nested name specifier; did you mean
'::'?
return tm ? (const int)tm : nothing;
^
::
clang_tm.cpp:7:28: error: no member named 'nothing' in 'tm'; did you mean
simply 'nothing'?
return tm ? (const int)tm : nothing;
^~~~~~~~~~~~
nothing
clang_tm.cpp:6:15: note: 'nothing' declared here
const int nothing = 0;
^
clang_tm.cpp:7:40: error: expected ':'
return tm ? (const int)tm : nothing;
^
:
clang_tm.cpp:7:15: note: to match this '?'
return tm ? (const int)tm : nothing;
^
clang_tm.cpp:7:40: error: expected expression
return tm ? (const int)tm : nothing;
^
4 errors generated.
This is with:
% clang -v|&fgrep -v 'Found candidate'
Debian clang version 3.4-2 (tags/RELEASE_34/final) (based on LLVM 3.4)
Target: x86_64-pc-linux-gnu
Thread model: posix
Selected GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/4.8
Removing the cast works around the bug (or at least what looks like a bug to
me), but this wasn't immediately clear when the error happened in the real code
which happened to include <time.h> and then use a local variable called "tm".</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>