https://gcc.gnu.org/bugzilla/show_bug.cgi?id=72825
Bug ID: 72825 Summary: ICE on invalid C++ code on x86_64-linux-gnu (internal compiler error: tree check: expected array_type, have error_mark in array_ref_low_bound, at tree.c:13013) Product: gcc Version: 7.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: chengniansun at gmail dot com Target Milestone: --- $ g++-trunk -v Using built-in specs. COLLECT_GCC=g++-trunk COLLECT_LTO_WRAPPER=/usr/local/gcc-trunk/libexec/gcc/x86_64-pc-linux-gnu/7.0.0/lto-wrapper Target: x86_64-pc-linux-gnu Configured with: ../gcc-source-trunk/configure --enable-languages=c,c++,lto --prefix=/usr/local/gcc-trunk --disable-bootstrap Thread model: posix gcc version 7.0.0 20160805 (experimental) [trunk revision 239171] (GCC) $ $ g++-trunk small.C small.C:6:12: error: uninitialized const ‘Wrapper::msgPtr’ [-fpermissive] const char Wrapper::msgPtr[]; ^~~~~~~ small.C:6:12: error: storage size of ‘Wrapper::msgPtr’ isn’t known small.C: In static member function ‘static const char* Wrapper::m_fn1()’: small.C:4:48: internal compiler error: tree check: expected array_type, have error_mark in array_ref_low_bound, at tree.c:13013 static const char *m_fn1() { return &msgPtr[0]; } ~~~~~~~~^ 0x10409ec tree_check_failed(tree_node const*, char const*, int, char const*, ...) ../../gcc-source-trunk/gcc/tree.c:9742 0x105ec87 tree_check(tree_node*, char const*, int, char const*, tree_code) ../../gcc-source-trunk/gcc/tree.h:3023 0x105ec87 array_ref_low_bound(tree_node*) ../../gcc-source-trunk/gcc/tree.c:13013 0xb5f9cf gimplify_compound_lval ../../gcc-source-trunk/gcc/gimplify.c:2117 0xb57891 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*), int) ../../gcc-source-trunk/gcc/gimplify.c:10422 0xb59126 gimplify_addr_expr ../../gcc-source-trunk/gcc/gimplify.c:5211 0xb59126 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*), int) ../../gcc-source-trunk/gcc/gimplify.c:10516 0xb6a287 gimplify_modify_expr ../../gcc-source-trunk/gcc/gimplify.c:4808 0xb59c1d gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*), int) ../../gcc-source-trunk/gcc/gimplify.c:10470 0xb5c576 gimplify_stmt(tree_node**, gimple**) ../../gcc-source-trunk/gcc/gimplify.c:5804 0xb58e79 gimplify_and_add(tree_node*, gimple**) ../../gcc-source-trunk/gcc/gimplify.c:427 0xb58e79 gimplify_return_expr ../../gcc-source-trunk/gcc/gimplify.c:1371 0xb58e79 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*), int) ../../gcc-source-trunk/gcc/gimplify.c:10719 0xb5c576 gimplify_stmt(tree_node**, gimple**) ../../gcc-source-trunk/gcc/gimplify.c:5804 0xb6baee gimplify_body(tree_node*, bool) ../../gcc-source-trunk/gcc/gimplify.c:11653 0xb6c0e6 gimplify_function_tree(tree_node*) ../../gcc-source-trunk/gcc/gimplify.c:11809 0x9d5a37 cgraph_node::analyze() ../../gcc-source-trunk/gcc/cgraphunit.c:625 0x9d8ca5 analyze_functions ../../gcc-source-trunk/gcc/cgraphunit.c:1086 0x9d9a7c symbol_table::finalize_compilation_unit() ../../gcc-source-trunk/gcc/cgraphunit.c:2547 Please submit a full bug report, with preprocessed source if appropriate. Please include the complete backtrace with any bug report. See <http://gcc.gnu.org/bugs.html> for instructions. $ $ cat small.C class Wrapper { public: static const char msgPtr[]; static const char *m_fn1() { return &msgPtr[0]; } }; const char Wrapper::msgPtr[]; int main() { Wrapper::m_fn1(); } $