[Bug c/92833] ice for broken C code

2019-12-30 Thread keremkat+gcc at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92833

Kerem Kat  changed:

   What|Removed |Added

 CC||keremkat+gcc at gmail dot com

--- Comment #3 from Kerem Kat  ---
This is caused by c_parser_peek_conflict_marker peeking into 4 tokens at once
whereas c_parser_consume_token expects a maximum of 3 tokens to be peeked.

In this case, last token is EOF and it is swallowed by c_parser_consume_token,
leading to ICE within the next c_parser_skip_to_end_of_block_or_statement
invocation which tries to read pfile->buffer that was popped to become empty
via _cpp_pop_buffer.


Minimal test case is six less than signs:

<<<<<<


Full stack trace:

92833-ice.c:1:1: error: expected identifier or ‘(’ before ‘<<’ token
1 | <<<<<<
  | ^~
92833-ice.c:1:1: internal compiler error: Segmentation fault
0xe150f3 crash_signal
dir/gcc/toplev.c:328
0x187c684 _cpp_lex_direct
dir/libcpp/lex.c:2725
0x187c3e4 _cpp_lex_token
dir/libcpp/lex.c:2608
0x1886d77 cpp_get_token_1
dir/libcpp/macro.c:2707
0x8ef0e5 c_lex_with_flags(tree_node**, unsigned int*, unsigned char*, int)
dir/gcc/c-family/c-lex.c:458
0x8426b5 c_lex_one_token
dir/gcc/c/c-parser.c:270
0x842bbe c_parser_peek_token(c_parser*)
dir/gcc/c/c-parser.c:474
0x843ffd c_parser_skip_to_end_of_block_or_statement
dir/gcc/c/c-parser.c:1322
0x8455bd c_parser_declaration_or_fndef
dir/gcc/c/c-parser.c:2123
0x844a1d c_parser_external_declaration
dir/gcc/c/c-parser.c:1742
0x844566 c_parser_translation_unit
dir/gcc/c/c-parser.c:1615
0x884ed7 c_parse_file()
dir/gcc/c/c-parser.c:21704
0x8f9b43 c_common_parse_file()
dir/gcc/c-family/c-opts.c:1186

[Bug c/92833] ice for broken C code

2019-12-30 Thread keremkat+gcc at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92833

--- Comment #4 from Kerem Kat  ---
Please assign to me.

[Bug c/79412] [8/9/10 Regression] ICE in fold_convert_loc, at fold-const.c:2239

2019-12-30 Thread keremkat+gcc at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79412

Kerem Kat  changed:

   What|Removed |Added

 CC||keremkat+gcc at gmail dot com

--- Comment #7 from Kerem Kat  ---
Not reproducible on trunk (10).

$ gcc z1.c
z1.c:6:5: error: conflicting types for ‘a’
6 | int a[] = {2};
  | ^
z1.c:1:5: note: previous declaration of ‘a’ was here
1 | int a;
  | ^
z1.c:4: confused by earlier errors, bailing out

[Bug c/92833] ice for broken C code

2019-12-30 Thread keremkat+gcc at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92833

--- Comment #6 from Kerem Kat  ---
Created attachment 47569
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=47569&action=edit
fix ice

PR c/92833
* parser.c (c_parser_consume_token): Fix peeked
token stack pop to support 4 available tokens.

* c-c++-common/pr92833-*.c: New tests.

[Bug c/79412] [8/9/10 Regression] ICE in fold_convert_loc, at fold-const.c:2239

2019-12-30 Thread keremkat+gcc at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79412

--- Comment #8 from Kerem Kat  ---
^ correction> not reproducible with 9.2.1, reproducible with gcc-10 trunk as:

$ gcc z1.c
79412-ice.c:6:5: error: conflicting types for ‘a’
6 | int a[] = {2};
  | ^
79412-ice.c:1:5: note: previous declaration of ‘a’ was here
1 | int a;
  | ^
79412-ice.c: In function ‘fn1’:
79412-ice.c:4:4: internal compiler error: in fold_convert_loc, at
fold-const.c:2435
4 |   a++;
  |   ~^~
0x61908f fold_convert_loc(unsigned int, tree_node*, tree_node*)
../../gcc/gcc/fold-const.c:2435
0xb29b8e gimplify_self_mod_expr(tree_node**, gimple**, gimple**, bool,
tree_node*)
../../gcc/gcc/gimplify.c:3178
0xb2305f gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
../../gcc/gcc/gimplify.c:13496
0xb26e5a gimplify_stmt(tree_node**, gimple**)
../../gcc/gcc/gimplify.c:6814
0xb27c5e gimplify_bind_expr
../../gcc/gcc/gimplify.c:1424
0xb24569 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
../../gcc/gcc/gimplify.c:13767
0xb26e5a gimplify_stmt(tree_node**, gimple**)
../../gcc/gcc/gimplify.c:6814
0xb289de gimplify_body(tree_node*, bool)
../../gcc/gcc/gimplify.c:14814
0xb28dd7 gimplify_function_tree(tree_node*)
../../gcc/gcc/gimplify.c:14958
0x984337 cgraph_node::analyze()
../../gcc/gcc/cgraphunit.c:669
0x987266 analyze_functions
../../gcc/gcc/cgraphunit.c:1212
0x987eb6 symbol_table::finalize_compilation_unit()
../../gcc/gcc/cgraphunit.c:2958