<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 - pointer to member of forward declared class inside a template class causes a crash on Windows"
href="https://bugs.llvm.org/show_bug.cgi?id=51538">51538</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>pointer to member of forward declared class inside a template class causes a crash on Windows
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>12.0
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Windows NT
</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>-New Bugs
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>jakub.lopuszanski@oracle.com
</td>
</tr>
<tr>
<th>CC</th>
<td>htmldeveloper@gmail.com, llvm-bugs@lists.llvm.org, neeilans@live.com, richard-llvm@metafoo.co.uk
</td>
</tr></table>
<p>
<div>
<pre>The following short code:
```
template <typename> struct a;
template <typename b, int b::*> struct c;
template <size_t = 512> class d {
class e;
typedef a<c<e, &e::f>> g;
class e {
int f;
friend d;
};
};
d<> rec_init_offsets_index;
```
crashes on Windows when compiled with (under GitBash):
$ '/c/Program Files/LLVM12.0.1/bin/clang.exe' -cc1 -gcodeview
-debug-info-kind=limited -fms-compatibility -emit-llvm small.cpp
I've tested 12.0.1, 11.0.0, 10.0.0, 8.0.1, 7.1.0 versions installed using
installers from your official website, and all of them crash.
Also, I've asked a coworker with Windows+clang12, and it crashes for him, too.
Finally, the code seems to compile just fine on linux
5.4.17-2011.6.2.el8uek.x86_64 with clang 11.0.0.
Also, please note that:
```
template <typename> struct a;
template <typename b, int b::*> struct c;
template <size_t = 512> class d {
class e {
int f;
friend d;
};
typedef a<c<e, &e::f>> g;
};
d<> rec_init_offsets_index;
```
(where I've moved `class e` definition sooner) compiles just fine.
The mimimized snippet was reduced from a 4MB source, but I guess it resembles
this part of the real code:
```
template <size_t SIZE = DYN_ARRAY_DATA_SIZE>
class dyn_buf_t {
public:
class block_t;
typedef UT_LIST_NODE_T(block_t) block_node_t;
typedef UT_LIST_BASE_NODE_T(block_t, m_node) block_list_t;
class block_t {
public:
block_t() {
ut_ad(MAX_DATA_SIZE <= (2 << 15));
init();
}
..
snip (you can see similar code at
<a href="https://github.com/mysql/mysql-server/blob/d0b6dddb74b8f2b042a69c92eced3561176a809d/storage/innobase/include/dyn0buf.h#L54">https://github.com/mysql/mysql-server/blob/d0b6dddb74b8f2b042a69c92eced3561176a809d/storage/innobase/include/dyn0buf.h#L54</a>)
```
where:
```
#define UT_LIST_NODE_T(t) ut_list_node<t>
#define UT_LIST_BASE_NODE_T(t, m) \
ut_list_base<t, ut_list_base_explicit_getter<t, &t::m>>
```
(more at
<a href="https://github.com/mysql/mysql-server/blob/d0b6dddb74b8f2b042a69c92eced3561176a809d/storage/innobase/include/ut0lst.h#L63">https://github.com/mysql/mysql-server/blob/d0b6dddb74b8f2b042a69c92eced3561176a809d/storage/innobase/include/ut0lst.h#L63</a>
<a href="https://github.com/mysql/mysql-server/blob/d0b6dddb74b8f2b042a69c92eced3561176a809d/storage/innobase/include/ut0lst.h#L252">https://github.com/mysql/mysql-server/blob/d0b6dddb74b8f2b042a69c92eced3561176a809d/storage/innobase/include/ut0lst.h#L252</a>
)
The fix seems to be to move the `typedef UT_LIST_BASE_NODE_T(block_t, m_node)
block_list_t;` below the `class block_t {...};` definition.
I have no idea what makes this Windows-specific.
Let me also take this occasion, to share my frustration on the very scarce info
you provide on how to actually run C-Reduce on Windows at
<a href="https://llvm.org/docs/HowToSubmitABug.html#frontend-crash">https://llvm.org/docs/HowToSubmitABug.html#frontend-crash</a> (it took me two days
to figure out how to make it work:
<a href="https://github.com/zjturner/creduce-windows/issues/2">https://github.com/zjturner/creduce-windows/issues/2</a>)</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>