<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 - declaring a function with a computed typedef is confused as a data member by definition"
href="https://bugs.llvm.org/show_bug.cgi?id=42354">42354</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>declaring a function with a computed typedef is confused as a data member by definition
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>8.0
</td>
</tr>
<tr>
<th>Hardware</th>
<td>Macintosh
</td>
</tr>
<tr>
<th>OS</th>
<td>All
</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++17
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>alisdairm@me.com
</td>
</tr>
<tr>
<th>CC</th>
<td>blitzrakete@gmail.com, erik.pilkington@gmail.com, llvm-bugs@lists.llvm.org, richard-llvm@metafoo.co.uk
</td>
</tr></table>
<p>
<div>
<pre>Note that this bug is a real corner case unlikely to occur in production code,
but bit us in experimental coding.
The following program should compile equivalently, regardless of the definition
of the SHOW_BUG macro:
#include <type_traits>
#define SHOW_ERROR 1
using namespace std;
template <typename T>
struct why_me {
#if defined(SHOW_ERROR)
using what_the = conditional_t<is_const_v<T>, void() noexcept, void()>;
#else
using what_the = void() noexcept(is_const_v<T>);
#endif
what_the heck;
};
template <typename T>
void why_me<T>::heck() noexcept(is_const_v<T>) {}
int main() {
why_me<int> x = {};
x.heck();
why_me<int> y = {};
y.heck();
}
However, when SHOW_BUG is defined, we get the following errors:
to_heck_with_it.cpp:20:17: error: redefinition of 'heck' as different kind of
symbol
void why_me<T>::heck() noexcept(is_const_v<T>) {}
^
to_heck_with_it.cpp:16:13: note: previous definition is here
what_the heck;
^
to_heck_with_it.cpp:16:13: error: data member instantiated with function type
'why_me<int>::what_the' (aka 'void ()')
what_the heck;
^
to_heck_with_it.cpp:23:16: note: in instantiation of template class
'why_me<int>' requested here
why_me<int> x = {};
^
2 errors generated.
The program compiles and runs as expected when SHOW_BUG is not defined.</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>