<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 - Variable template inside the class causes compiler crash"
href="https://bugs.llvm.org/show_bug.cgi?id=45109">45109</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Variable template inside the class causes compiler crash
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>9.0
</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>enhancement
</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>unixod@gmail.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>Created <span class=""><a href="attachment.cgi?id=23204" name="attach_23204" title="Clang's stderr + -save-temps">attachment 23204</a> <a href="attachment.cgi?id=23204&action=edit" title="Clang's stderr + -save-temps">[details]</a></span>
Clang's stderr + -save-temps
An issue I'm going to describe I've encountered both in Clang 9 and Clang thunk
(<a href="https://godbolt.org/z/jffEf_">https://godbolt.org/z/jffEf_</a>) but not in GCC.
The following code causes compiler crash:
-------snippet(A) begin---------
template<auto>
struct X {};
template<typename T>
class Foo {
private:
template<auto v>
static constexpr auto copy = v; // (1)
public:
template<auto v>
Foo(X<v>)
{
auto val = copy<v>;
};
};
int main()
{
Foo<int> b{X<3>{}};
}
-------snippet(A) end---------
If the variable template (1) is moved out from the class (put above Foo), code
is compiled successfully.
The similar issue happens in a little bit different code (in this case,
compiler isn't crashed, but compilation results in error):
-------snippet(B) begin---------
template<auto>
struct X {};
template<typename T>
class Foo {
private:
template<auto v>
static constexpr auto copy = v; // (1)
public:
template<auto v>
Foo(X<v>)
: val{copy<v>}
{};
T val;
};
int main()
{
Foo<int> b{X<3>{}};
}
-------snippet(B) end---------
This is again can be worked around by defining a variable template (1) outside
the class.</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>