https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95768
Bug ID: 95768 Summary: -march=sandybridge -O2 -Wall crashes as 'during GIMPLE pass: uninit ... Segmentation fault' Product: gcc Version: 11.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: slyfox at inbox dot ru Target Milestone: --- SIGSEGV initially observed on qtcore-5.14.2 package. Here is the minimal(ish) reproducer: // $ cat bug.cc extern "C" void *malloc(unsigned long); class a { public: enum c { Array }; }; class d { public: static int e(int); }; class f { public: int g; void operator=(int) { d::e(g); } }; template < typename, int, int > using h = f; template < int i, int j > using k = h< int, i, j >; template < int i, int j > using l = h< int, i, j >; class m { public: k< 0, 1 > is_object; k< 1, 1 > length; }; class n { public: m *o() { return (m *)this; } }; class p { public: enum {} alloc; n *header; p(a::c) { header = (n *)malloc(alloc); m b = *header->o(); b.length = 0; } }; void detach2() { p(a::Array); } LANG=C /usr/bin/x86_64-pc-linux-gnu-g++ -march=sandybridge -O2 -Wall -c bug.cc -o bug.o bug.cc: In constructor 'p::p(a::c)': bug.cc:32:26: warning: '*<unknown>.p::alloc' is used uninitialized [-Wuninitialized] 32 | header = (n *)malloc(alloc); | ^~~~~ ' during GIMPLE pass: uninit In function 'void detach2()': Segmentation fault 37 | void detach2() { p(a::Array); } | ^~~~~~~ 0xa9c91f crash_signal ../../gcc-11.0.0_pre9999/gcc/toplev.c:328 0x7f2dc77d2c3f ??? /usr/src/debug/sys-libs/glibc-2.31-r5/glibc-2.31/signal/../sysdeps/unix/sysv/linux/x86_64/sigaction.c:0 0xce7494 location_wrapper_p(tree_node const*) ../../gcc-11.0.0_pre9999/gcc/tree.h:3999 0xce7494 tree_strip_any_location_wrapper(tree_node*) ../../gcc-11.0.0_pre9999/gcc/tree.h:4011 0xce7494 integer_onep(tree_node const*) ../../gcc-11.0.0_pre9999/gcc/tree.c:2573 0x4e0ee3 dump_expr ../../gcc-11.0.0_pre9999/gcc/cp/error.c:2386 0x4e3640 expr_to_string(tree_node*) ../../gcc-11.0.0_pre9999/gcc/cp/error.c:3109 0x4e3cfc cp_printer ../../gcc-11.0.0_pre9999/gcc/cp/error.c:4264 0x13e0646 pp_format(pretty_printer*, text_info*) ../../gcc-11.0.0_pre9999/gcc/pretty-print.c:1475 0x13d48e2 diagnostic_report_diagnostic(diagnostic_context*, diagnostic_info*) ../../gcc-11.0.0_pre9999/gcc/diagnostic.c:1159 0x13d683a diagnostic_impl ../../gcc-11.0.0_pre9999/gcc/diagnostic.c:1309 0x13d683a warning_at(unsigned int, int, char const*, ...) ../../gcc-11.0.0_pre9999/gcc/diagnostic.c:1446 0xc5e7ed maybe_warn_operand ../../gcc-11.0.0_pre9999/gcc/tree-ssa-uninit.c:418 0xc619e9 warn_uninitialized_vars ../../gcc-11.0.0_pre9999/gcc/tree-ssa-uninit.c:640 0xc66016 execute ../../gcc-11.0.0_pre9999/gcc/tree-ssa-uninit.c:2936 Please submit a full bug report, with preprocessed source if appropriate. Please include the complete backtrace with any bug report. See <https://bugs.gentoo.org/> for instructions.