<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 - clang/libclang crashes on parsing (std >= c++14) on all versions (recursion bug)"
href="https://bugs.llvm.org/show_bug.cgi?id=46161">46161</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>clang/libclang crashes on parsing (std >= c++14) on all versions (recursion bug)
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>unspecified
</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++14
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>xutaxkamay@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=23562" name="attach_23562" title="Code source that causes the crash.">attachment 23562</a> <a href="attachment.cgi?id=23562&action=edit" title="Code source that causes the crash.">[details]</a></span>
Code source that causes the crash.
Hello dear LLVM/clang developers.
I've discovered a crash with clang that seem to happen on every versions when
std >= 14.
I have tested with clang version 8,9,10,11, it has the same problem everywhere.
My thoughts are that it seems to happen when one template function have the
same name, same arguments and template arguments, when using template
parameters packs as last template argument.
When clang tries to parse it, it is processing the template function1 in
compile-time for creating the function1 that will be used next for compiling,
and clang resolves it recursively by calling the wrong template function1
instead of calling template function2.
template function1 and template function2 have the same function name (to avoid
confusion) of course.
Results:
....
1. main.cpp:24:29: current parser token ')'
2. main.cpp:23:1: parsing function body 'main'
3. main.cpp:23:1: in compound statement ('{}')
4. ./types.h:73:27: instantiating function definition 'XLib::CVFunc<0,
void (*)()>'
5. ./types.h:61:27: instantiating function definition 'XLib::VFunc<0, void
(*)()>'
6. ./types.h:61:27: instantiating function definition 'XLib::VFunc<0, void
(*(*)())()>'
7. ./types.h:61:27: instantiating function definition 'XLib::VFunc<0, void
(*(*(*)())())()>'
8. ./types.h:61:27: instantiating function definition 'XLib::VFunc<0, void
(*(*(*(*)())())())()>'
....
I've attached an example of source code inside the attachments so you can debug
it yourself because it is easily reproducible, in hope it could help.
Commands used:
clang-8 -std=c++14 -o main main.cpp
clang-9 -std=c++14 -o main main.cpp
clang-11 -std=c++14 -o main main.cpp
clang-11 -std=c++14 -o main main.cpp
....
I would be glad that it could be fixed, even if it's my coding style that isn't
very pleasant...
Thank you!</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>