<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 --- - fail to diagnose use of member in static method, crash later in codegen"
href="http://llvm.org/bugs/show_bug.cgi?id=21923">21923</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>fail to diagnose use of member in static method, crash later in codegen
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</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>C++
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>nlewycky@google.com
</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>Testcase:
template <typename T>
struct Base {
int member;
};
template <typename T>
struct Derived : public Base<T> {
static void Test();
using Base<T>::member;
};
template <typename T>
void Derived<T>::Test() {
member; // error: may not access member in static method.
}
template class Derived<int>;
GCC says:
$ g++ -std=gnu++11 b18754991.cc
b18754991.cc: In instantiation of ‘static void Derived<T>::Test() [with T =
int]’:
b18754991.cc:17:16: required from here
b18754991.cc:3:7: error: invalid use of member ‘Base<int>::member’ in static
member function
int member;
^
b18754991.cc:14:3: error: from this location
member; // error: may not access member in static method.
^
Clang finds no error here, then crashes in codegen with:
$ clang -cc1 -std=gnu++11 b18754991.cc -emit-llvm-only
b18754991.cc:14:3: warning: expression result unused
member; // error: may not access member in static method.
^~~~~~
b18754991.cc:17:16: note: in instantiation of member function
'Derived<int>::Test' requested here
template class Derived<int>;
^
Unhandled DeclRefExpr
UNREACHABLE executed at CGExpr.cpp:2010!
[...]</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>