[Bug sanitizer/85213] [8 Regression] -fsanitize=undefined internal compiler error: in fold_convert_loc, at fold-const.c:2402

2018-04-06 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85213

Jakub Jelinek  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution|--- |FIXED
   Assignee|unassigned at gcc dot gnu.org  |jakub at gcc dot gnu.org

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

[Bug sanitizer/85213] [8 Regression] -fsanitize=undefined internal compiler error: in fold_convert_loc, at fold-const.c:2402

2018-04-06 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85213

--- Comment #6 from Jakub Jelinek  ---
Author: jakub
Date: Fri Apr  6 11:24:36 2018
New Revision: 259167

URL: https://gcc.gnu.org/viewcvs?rev=259167=gcc=rev
Log:
PR sanitizer/85213
* fold-const.c (twoval_comparison_p): Remove SAVE_P argument and don't
look through SAVE_EXPRs with non-side-effects argument.  Adjust
recursive calls.
(fold_comparison): Adjust twoval_comparison_p caller, don't handle
save_p here.

* c-c++-common/ubsan/pr85213.c: New test.

Added:
trunk/gcc/testsuite/c-c++-common/ubsan/pr85213.c
Modified:
trunk/gcc/ChangeLog
trunk/gcc/fold-const.c
trunk/gcc/testsuite/ChangeLog

[Bug sanitizer/85213] [8 Regression] -fsanitize=undefined internal compiler error: in fold_convert_loc, at fold-const.c:2402

2018-04-05 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85213

--- Comment #5 from Jakub Jelinek  ---
unshare_expr doesn't unshare the STATEMENT_LISTs embedded inside of it
(and wonder what would Alex' code do if we have two separate DEBUG_BEGIN_STMTs
for the same statement).

[Bug sanitizer/85213] [8 Regression] -fsanitize=undefined internal compiler error: in fold_convert_loc, at fold-const.c:2402

2018-04-05 Thread rguenth at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85213

--- Comment #4 from Richard Biener  ---
(In reply to Jakub Jelinek from comment #3)
> The problem is that twoval_comparison_p breaks appart SAVE_EXPR if their
> argument has no side effects.
> First, cp_build_binary_op calls save_expr on:
> (__builtin_expect ((long int) (# DEBUG BEGIN STMT;
> x != 0; ? 0 : 1), (long int) NON_LVALUE_EXPR <3>) == 0) * -1;
> and that resulting SAVE_EXPR is used in 2+ places, where one of them is a
> comparison against INTEGER_CST, which is optimized using twoval_comparison_p
> as
> another SAVE_EXPR with
> __builtin_expect ((long int) (# DEBUG BEGIN STMT;
> x != 0; ? 0 : 1), (long int) NON_LVALUE_EXPR <3>) == 0;
> body.  As mostly_copy_tree_r does not unshare STATEMENT_LISTs, we hand over
> to the gimplifier the above two SAVE_EXPRs and both contain the same
> STATEMENT_LIST, so we try to gimplify it twice, which as we know from other
> PRs doesn't really work at all.
> Now, not looking through SAVE_EXPRs in twoval_comparison_p if it contains a
> STATEMENT_LIST might result in -fcompare-debug failures, because with -g0
> there could be no STATEMENT_LIST, while with -g we have one.
> Not sure what our options are, besides just killing the SAVE_EXPR handling
> in twoval_comparison_p.

unshare the expression in twoval_comparison_p?

[Bug sanitizer/85213] [8 Regression] -fsanitize=undefined internal compiler error: in fold_convert_loc, at fold-const.c:2402

2018-04-05 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85213

Jakub Jelinek  changed:

   What|Removed |Added

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

--- Comment #3 from Jakub Jelinek  ---
The problem is that twoval_comparison_p breaks appart SAVE_EXPR if their
argument has no side effects.
First, cp_build_binary_op calls save_expr on:
(__builtin_expect ((long int) (# DEBUG BEGIN STMT;
x != 0; ? 0 : 1), (long int) NON_LVALUE_EXPR <3>) == 0) * -1;
and that resulting SAVE_EXPR is used in 2+ places, where one of them is a
comparison against INTEGER_CST, which is optimized using twoval_comparison_p as
another SAVE_EXPR with
__builtin_expect ((long int) (# DEBUG BEGIN STMT;
x != 0; ? 0 : 1), (long int) NON_LVALUE_EXPR <3>) == 0;
body.  As mostly_copy_tree_r does not unshare STATEMENT_LISTs, we hand over to
the gimplifier the above two SAVE_EXPRs and both contain the same
STATEMENT_LIST, so we try to gimplify it twice, which as we know from other PRs
doesn't really work at all.
Now, not looking through SAVE_EXPRs in twoval_comparison_p if it contains a
STATEMENT_LIST might result in -fcompare-debug failures, because with -g0 there
could be no STATEMENT_LIST, while with -g we have one.
Not sure what our options are, besides just killing the SAVE_EXPR handling in
twoval_comparison_p.

[Bug sanitizer/85213] [8 Regression] -fsanitize=undefined internal compiler error: in fold_convert_loc, at fold-const.c:2402

2018-04-05 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85213

Jakub Jelinek  changed:

   What|Removed |Added

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

--- Comment #2 from Jakub Jelinek  ---
I'll handle this.

[Bug sanitizer/85213] [8 Regression] -fsanitize=undefined internal compiler error: in fold_convert_loc, at fold-const.c:2402

2018-04-04 Thread mpolacek at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85213

Marek Polacek  changed:

   What|Removed |Added

 Status|UNCONFIRMED |NEW
   Last reconfirmed||2018-04-04
 CC||mpolacek at gcc dot gnu.org
   Target Milestone|--- |8.0
Summary|-fsanitize=undefined|[8 Regression]
   |internal compiler error: in |-fsanitize=undefined
   |fold_convert_loc, at|internal compiler error: in
   |fold-const.c:2402   |fold_convert_loc, at
   ||fold-const.c:2402
 Ever confirmed|0   |1

--- Comment #1 from Marek Polacek  ---
Started with r255947.