[llvm-bugs] [Bug 51538] New: pointer to member of forward declared class inside a template class causes a crash on Windows
via llvm-bugs
llvm-bugs at lists.llvm.org
Thu Aug 19 05:38:50 PDT 2021
https://bugs.llvm.org/show_bug.cgi?id=51538
Bug ID: 51538
Summary: pointer to member of forward declared class inside a
template class causes a crash on Windows
Product: clang
Version: 12.0
Hardware: PC
OS: Windows NT
Status: NEW
Severity: enhancement
Priority: P
Component: -New Bugs
Assignee: unassignedclangbugs at nondot.org
Reporter: jakub.lopuszanski at oracle.com
CC: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org,
neeilans at live.com, richard-llvm at metafoo.co.uk
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
https://github.com/mysql/mysql-server/blob/d0b6dddb74b8f2b042a69c92eced3561176a809d/storage/innobase/include/dyn0buf.h#L54)
```
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
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#L252
)
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
https://llvm.org/docs/HowToSubmitABug.html#frontend-crash (it took me two days
to figure out how to make it work:
https://github.com/zjturner/creduce-windows/issues/2)
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20210819/c050ba4d/attachment.html>
More information about the llvm-bugs
mailing list