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

            Bug ID: 78645
           Summary: ICE on invalid C++ code on x86_64-linux-gnu
                    (Segmentation fault, cxx_eval_call_expression)
           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: ---

$ gcc-trunk -v
Using built-in specs.
COLLECT_GCC=gcc-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 20161202 (experimental) [trunk revision 243153] (GCC) 
$ 
$ gcc-trunk small.C
small.C:4:29: error: invalid conversion from ‘bool (*)(int, Function) {aka bool
(*)(int, bool (*)(int))}’ to ‘Function {aka bool (*)(int)}’ [-fpermissive]
 static_assert(check(2, check));
                             ^
small.C:2:16: note:   initializing argument 2 of ‘constexpr bool check(int,
Function)’
 constexpr bool check(int x, Function p) { p(x); }
                ^~~~~
small.C:4:20:   in constexpr expansion of ‘check(2, ((Function)check))’
small.C:2:44:   in constexpr expansion of ‘p(x)’
small.C:4:31: internal compiler error: Segmentation fault
 static_assert(check(2, check));
                               ^
0xdf7cff crash_signal
        ../../gcc-source-trunk/gcc/toplev.c:333
0x8d83eb 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(tree_node* const&, unsigned
int)
        ../../gcc-source-trunk/gcc/hash-table.h:920
0x8cacf9 hash_map<tree_node*, tree_node*,
simple_hashmap_traits<default_hash_traits<tree_node*>, tree_node*>
>::remove(tree_node* const&)
        ../../gcc-source-trunk/gcc/hash-map.h:174
0x8cacf9 cxx_eval_call_expression
        ../../gcc-source-trunk/gcc/cp/constexpr.c:1655
0x8cc073 cxx_eval_constant_expression
        ../../gcc-source-trunk/gcc/cp/constexpr.c:3847
0x8cbf4c cxx_eval_constant_expression
        ../../gcc-source-trunk/gcc/cp/constexpr.c:4218
0x8cc0b6 cxx_eval_constant_expression
        ../../gcc-source-trunk/gcc/cp/constexpr.c:3966
0x8cc0b6 cxx_eval_constant_expression
        ../../gcc-source-trunk/gcc/cp/constexpr.c:3966
0x8caba6 cxx_eval_call_expression
        ../../gcc-source-trunk/gcc/cp/constexpr.c:1619
0x8cc073 cxx_eval_constant_expression
        ../../gcc-source-trunk/gcc/cp/constexpr.c:3847
0x8d3469 cxx_eval_outermost_constant_expr
        ../../gcc-source-trunk/gcc/cp/constexpr.c:4481
0x8d6968 maybe_constant_value_1
        ../../gcc-source-trunk/gcc/cp/constexpr.c:4685
0x8d6968 maybe_constant_value(tree_node*, tree_node*)
        ../../gcc-source-trunk/gcc/cp/constexpr.c:4709
0x83b925 finish_static_assert(tree_node*, tree_node*, unsigned int, bool)
        ../../gcc-source-trunk/gcc/cp/semantics.c:8774
0x7b58a0 cp_parser_static_assert
        ../../gcc-source-trunk/gcc/cp/parser.c:13597
0x7c8dc9 cp_parser_block_declaration
        ../../gcc-source-trunk/gcc/cp/parser.c:12587
0x7cf850 cp_parser_declaration
        ../../gcc-source-trunk/gcc/cp/parser.c:12488
0x7cfc54 cp_parser_declaration_seq_opt
        ../../gcc-source-trunk/gcc/cp/parser.c:12364
0x7cff98 cp_parser_translation_unit
        ../../gcc-source-trunk/gcc/cp/parser.c:4368
0x7cff98 c_parse_file()
        ../../gcc-source-trunk/gcc/cp/parser.c:38262
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
typedef bool (*Function)(int);
constexpr bool check(int x, Function p) { p(x); }

static_assert(check(2, check));
$

Reply via email to