https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89652

            Bug ID: 89652
           Summary: ICE during constexpr evaluation
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: dimitri.gorokhovik at free dot fr
  Target Milestone: ---

Created attachment 45930
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=45930&action=edit
Preprocessed source file proviking  the crash

Hi,

recent trunk crashes during constexpr eval (g++ (GCC) 9.0.1 20190310
(experimental))

The source code is in attachment (sorry, couldn't simplify more fast enough).
To run: ccplus1 -std=c++17 -O3 bug.cpp

The backtrace is below. It seems that the searching the hash map brings back
nullptr which is dereferenced straight away without checking -- not sure
whether nullptr is illegal value at this place.

#0  0x00000000008f2b3b in hash_table<hash_map<tree_node*, tree_node*,
simple_hashmap_traits<default_hash_traits<tree_node*>, tree_node*>
>::hash_entry, xcallocator>::remove_elt_with_hash (this=0x7fffffffd650,
comparable=@0x7fffffffd098: 0x7ffff53aaac0, hash=<optimized out>) at
../../srcdir/gcc/hash-table.h:939
#1  0x00000000008eda3e in hash_map<tree_node*, tree_node*,
simple_hashmap_traits<default_hash_traits<tree_node*>, tree_node*> >::remove (
    k=@0x7fffffffd098: 0x7ffff53aaac0, this=<optimized out>) at
../../srcdir/gcc/cp/constexpr.c:4261
#2  cxx_eval_loop_expr(constexpr_ctx const*, tree_node*, bool*, bool*,
tree_node**) () at ../../srcdir/gcc/cp/constexpr.c:4261
#3  0x00000000008e69e5 in cxx_eval_constant_expression(constexpr_ctx const*,
tree_node*, bool, bool*, bool*, tree_node**) ()
    at ../../srcdir/gcc/cp/constexpr.c:5112
#4  0x00000000008e7a60 in cxx_eval_statement_list (jump_target=0x7fffffffd430,
overflow_p=0x7fffffffd647, non_constant_p=0x7fffffffd646, t=<optimized out>, 
    ctx=0x7fffffffd270) at ../../srcdir/gcc/cp/constexpr.c:4142
#5  cxx_eval_constant_expression(constexpr_ctx const*, tree_node*, bool, bool*,
bool*, tree_node**) () at ../../srcdir/gcc/cp/constexpr.c:5012
#6  0x00000000008e781b in cxx_eval_constant_expression(constexpr_ctx const*,
tree_node*, bool, bool*, bool*, tree_node**) () at ../../srcdir/gcc/tree.h:3677
#7  0x00000000008e5ca2 in cxx_eval_call_expression(constexpr_ctx const*,
tree_node*, bool, bool*, bool*) () at ../../srcdir/gcc/cp/constexpr.c:1839
#8  0x00000000008e6f54 in cxx_eval_constant_expression(constexpr_ctx const*,
tree_node*, bool, bool*, bool*, tree_node**) ()
    at ../../srcdir/gcc/cp/constexpr.c:4495
#9  0x00000000008edcb7 in cxx_eval_outermost_constant_expr(tree_node*, bool,
bool, bool, tree_node*) () at ../../srcdir/gcc/cp/constexpr.c:5277
#10 0x00000000008f1039 in maybe_constant_value(tree_node*, tree_node*, bool) ()
at ../../srcdir/gcc/cp/constexpr.c:5509
#11 0x0000000000a8b05f in store_init_value(tree_node*, tree_node*,
vec<tree_node*, va_gc, vl_embed>**, int) () at
../../srcdir/gcc/cp/typeck2.c:843
#12 0x00000000009193f3 in check_initializer(tree_node*, tree_node*, int,
vec<tree_node*, va_gc, vl_embed>**) () at ../../srcdir/gcc/cp/decl.c:6522
#13 0x0000000000938c4d in cp_finish_decl(tree_node*, tree_node*, bool,
tree_node*, int) () at ../../srcdir/gcc/cp/decl.c:7196
#14 0x00000000009d43c8 in cp_parser_init_declarator(cp_parser*, int,
cp_decl_specifier_seq*, vec<deferred_access_check, va_gc, vl_embed>*, bool,
bool, int, bool*, tree_node**, unsigned int*, tree_node**) () at
../../srcdir/gcc/cp/parser.c:20468
#15 0x00000000009b7dff in cp_parser_simple_declaration(cp_parser*, bool,
tree_node**) () at ../../srcdir/gcc/cp/parser.c:13492
#16 0x00000000009da7a1 in cp_parser_declaration(cp_parser*) () at
../../srcdir/gcc/cp/parser.c:13189
#17 0x00000000009daf1d in cp_parser_translation_unit (parser=0x7ffff7ff6ab0) at
../../srcdir/gcc/cp/parser.c:4698
#18 c_parse_file() () at ../../srcdir/gcc/cp/parser.c:41114
#19 0x0000000000ae138c in c_common_parse_file () at
../../srcdir/gcc/c-family/c-opts.c:1155
#20 0x0000000000f91cf0 in compile_file () at ../../srcdir/gcc/toplev.c:456
#21 0x00000000008a3755 in do_compile () at ../../srcdir/gcc/toplev.c:2204
#22 toplev::main(int, char**) () at ../../srcdir/gcc/toplev.c:2339
#23 0x00000000008a711f in main (argc=3, argv=0x7fffffffde08) at
../../srcdir/gcc/main.c:39

Reply via email to