[LLVMbugs] [Bug 19748] New: Parse error after a cast of a variable with the same name as an existing struct in a ternary operator
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Wed May 14 15:45:25 PDT 2014
http://llvm.org/bugs/show_bug.cgi?id=19748
Bug ID: 19748
Summary: Parse error after a cast of a variable with the same
name as an existing struct in a ternary operator
Product: clang
Version: unspecified
Hardware: PC
OS: Windows NT
Status: NEW
Severity: normal
Priority: P
Component: C++
Assignee: unassignedclangbugs at nondot.org
Reporter: vz-llvm at zeitlins.org
CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
Classification: Unclassified
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".
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20140514/f8b8be83/attachment.html>
More information about the llvm-bugs
mailing list