<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 --- - may need to parse class member function bodies out-of-order"
href="http://llvm.org/bugs/show_bug.cgi?id=16082">16082</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>may need to parse class member function bodies out-of-order
</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++11
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>richard-llvm@metafoo.co.uk
</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:
template<typename T, T v> struct ic {};
template<typename Type>
class Test
{
public:
constexpr Test(const Type val) : _value(val) {}
// constexpr Type get() const {return _value;} // #1
static void test() {
static constexpr Test<int> x(42);
ic<int, x.get()> i;
}
constexpr Type get() const {return _value;} // #2
protected:
Type _value;
};
void f() { Test<int>::test(); }
With #1 uncommented, both g++ and Clang accept. With #2 uncommented, both
reject (because we've not yet parsed the body of Test::get when we try to
instantiate it within the non-dependent constant expression 'x.get()'). EDG
accepts either way, and this code does not seem to be obviously ill-formed.
Perhaps we should trigger parsing of a member function body (a la
-fdelayed-template-parsing) if it's needed from another member function's body?
On the other hand, even EDG rejects this:
struct A {
void f() {
static_assert(g(), "");
}
static constexpr bool g() { return true; }
};
... which we could accept with the same technique.</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>