From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 100642 invoked by alias); 30 Aug 2015 14:32:13 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 100595 invoked by uid 48); 30 Aug 2015 14:32:09 -0000 From: "miyuki at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/67398] Segfault when template static references another template Date: Sun, 30 Aug 2015 14:32:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 5.2.1 X-Bugzilla-Keywords: ice-on-invalid-code X-Bugzilla-Severity: normal X-Bugzilla-Who: miyuki at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2015-08/txt/msg02048.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67398 --- Comment #6 from Mikhail Maltsev --- $ cat test4_min.cc struct B { void *extradata; }; template class C { static const B b; virtual void m_fn1() { (void)b; } }; template struct strdata_t { int data[]; }; template const B C::b{strdata_t{}.data}; C 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::b{strdata_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::b{strdata_t{}.data};