[Bug tree-optimization/89566] [9 Regression] ICE on compilable C++ code: in gimple_call_arg, at gimple.h:3166

2019-03-05 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89566

Jakub Jelinek  changed:

   What|Removed |Added

 Status|ASSIGNED|RESOLVED
 Resolution|--- |FIXED

--- Comment #5 from Jakub Jelinek  ---
Fixed.

(In reply to Martin Sebor from comment #3)
As for a better way, you haven't proposed anything.  The thing is that an
indirect call can be folded into direct at hundreds of places through the
optimizations, so calling a function that does the checking before you start
trusting the arguments is what we have now, the bug is if it is not called or
(like in this case) not used with care.

[Bug tree-optimization/89566] [9 Regression] ICE on compilable C++ code: in gimple_call_arg, at gimple.h:3166

2019-03-05 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89566

--- Comment #4 from Jakub Jelinek  ---
Author: jakub
Date: Tue Mar  5 08:43:16 2019
New Revision: 269384

URL: https://gcc.gnu.org/viewcvs?rev=269384=gcc=rev
Log:
PR tree-optimization/89566
* gimple-ssa-sprintf.c (sprintf_dom_walker::handle_gimple_call):
Set info.fncode to BUILT_IN_NONE if gimple_call_builtin_p failed.
Punt if get_user_idx_format succeeds, but idx_format argument is
not provided or doesn't have pointer type, or if idx_args is above
number of provided arguments.

* c-c++-common/pr89566.c: New test.

Added:
trunk/gcc/testsuite/c-c++-common/pr89566.c
Modified:
trunk/gcc/ChangeLog
trunk/gcc/gimple-ssa-sprintf.c
trunk/gcc/testsuite/ChangeLog

[Bug tree-optimization/89566] [9 Regression] ICE on compilable C++ code: in gimple_call_arg, at gimple.h:3166

2019-03-04 Thread msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89566

Martin Sebor  changed:

   What|Removed |Added

   Keywords||ice-on-invalid-code
 CC||msebor at gcc dot gnu.org

--- Comment #3 from Martin Sebor  ---
This is a recurring problem.  I wonder how many more bugs like this there are. 
See for example below.  There ought to be a better way to prevent it than to
keep patching all the places in the middle end where the bad calls end up.

$ cat t.c && gcc -O2 -S -Wall t.c
void f (void)
{
  ((void (*)()) __builtin_free) ();
}
during RTL pass: expand
t.c: In function ‘f’:
t.c:3:4: internal compiler error: tree check: accessed operand 4 of call_expr
with 3 operands in maybe_emit_free_warning, at builtins.c:10608
3 |   ((void (*)()) __builtin_free) ();
  |   ~^~~
0x15b045d tree_operand_check_failed(int, tree_node const*, char const*, int,
char const*)
/src/gcc/svn/gcc/tree.c:10059
0x827e8c tree_operand_check(tree_node*, int, char const*, int, char const*)
/src/gcc/svn/gcc/tree.h:3676
0x9d4bdb maybe_emit_free_warning
/src/gcc/svn/gcc/builtins.c:10608
0x9cc317 expand_builtin(tree_node*, rtx_def*, rtx_def*, machine_mode, int)
/src/gcc/svn/gcc/builtins.c:8305
0xbf115c expand_expr_real_1(tree_node*, rtx_def*, machine_mode,
expand_modifier, rtx_def**, bool)
/src/gcc/svn/gcc/expr.c:11029
0xbe33e3 expand_expr_real(tree_node*, rtx_def*, machine_mode, expand_modifier,
rtx_def**, bool)
/src/gcc/svn/gcc/expr.c:8274
0xa06252 expand_expr
/src/gcc/svn/gcc/expr.h:279
0xa0f581 expand_call_stmt
/src/gcc/svn/gcc/cfgexpand.c:2724
0xa12f29 expand_gimple_stmt_1
/src/gcc/svn/gcc/cfgexpand.c:3691
0xa135e4 expand_gimple_stmt
/src/gcc/svn/gcc/cfgexpand.c:3850
0xa136fc expand_gimple_tailcall
/src/gcc/svn/gcc/cfgexpand.c:3897
0xa1bc7c expand_gimple_basic_block
/src/gcc/svn/gcc/cfgexpand.c:5863
0xa1da9a execute
/src/gcc/svn/gcc/cfgexpand.c:6509
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See  for instructions.

[Bug tree-optimization/89566] [9 Regression] ICE on compilable C++ code: in gimple_call_arg, at gimple.h:3166

2019-03-04 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89566

Jakub Jelinek  changed:

   What|Removed |Added

 Status|NEW |ASSIGNED
   Assignee|unassigned at gcc dot gnu.org  |jakub at gcc dot gnu.org

--- Comment #2 from Jakub Jelinek  ---
Created attachment 45878
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=45878=edit
gcc9-pr89566.patch

Untested fix.