[Bug c++/67398] Segfault when template static references another template
miyuki at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Sun Aug 30 14:32:00 GMT 2015
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67398
--- Comment #6 from Mikhail Maltsev <miyuki at gcc dot gnu.org> ---
$ cat test4_min.cc
struct B {
void *extradata;
};
template <typename>
class C {
static const B b;
virtual void m_fn1() { (void)b; }
};
template <typename>
struct strdata_t {
int data[];
};
template <typename T>
const B C<T>::b{strdata_t<T>{}.data};
C<int> c;
$ cc1plus test4_min.cc
test4_min.cc: In function 'void __static_initialization_and_destruction_0(int,
int)':
test4_min.cc:17:9: internal compiler error: in make_decl_rtl, at varasm.c:1306
const B C<T>::b{strdata_t<T>{}.data};
^
0xf53495 make_decl_rtl(tree_node*)
/home/miyuki/gcc/src/gcc/varasm.c:1302
0x9cfb79 expand_expr_real_1(tree_node*, rtx_def*, machine_mode,
expand_modifier, rtx_def**, bool)
/home/miyuki/gcc/src/gcc/expr.c:9525
0x9d9dc6 expand_expr
/home/miyuki/gcc/src/gcc/expr.h:255
0x9d9dc6 expand_expr_addr_expr_1
/home/miyuki/gcc/src/gcc/expr.c:7600
Reproduced on trunk. BTW, Clang accepts it, but issues a warning (apparently, I
overlooked that the error in my previous comment was caused by invalid
constexpr initialization):
test4_min.cc:17:17: warning: pointer is initialized by a temporary array, which
will be destroyed at the end of the full-expression
[-Waddress-of-array-temporary]
const B C<T>::b{strdata_t<T>{}.data};
More information about the Gcc-bugs
mailing list