[Bug sanitizer/80403] UBSAN: compile time crash with "type mismatch in binary expression" message in / and % expr

2017-04-13 Thread babokin at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80403

--- Comment #11 from Dmitry Babokin  ---
I confirm that the latest patch fixes all UBSAN compile time problems that I
have. Thanks!

Though correctness issues remain - PR80386.

[Bug sanitizer/80403] UBSAN: compile time crash with "type mismatch in binary expression" message in / and % expr

2017-04-13 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80403

--- Comment #10 from Jakub Jelinek  ---
Author: jakub
Date: Thu Apr 13 19:52:58 2017
New Revision: 246917

URL: https://gcc.gnu.org/viewcvs?rev=246917=gcc=rev
Log:
PR sanitizer/80403
* fold-const.c (fold_ternary_loc): Revert
use op0 instead of fold_convert_loc (loc, type, arg0) part of
2017-04-12 change.

* g++.dg/ubsan/pr80403-2.C: New test.

Added:
trunk/gcc/testsuite/g++.dg/ubsan/pr80403-2.C
Modified:
trunk/gcc/ChangeLog
trunk/gcc/fold-const.c
trunk/gcc/testsuite/ChangeLog

[Bug sanitizer/80403] UBSAN: compile time crash with "type mismatch in binary expression" message in / and % expr

2017-04-13 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80403

--- Comment #9 from Jakub Jelinek  ---
Created attachment 41195
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=41195=edit
gcc7-pr80403-2.patch

Oops, thinko in the committed patch.  COND_EXPR/VEC_COND_EXPR op0's type
doesn't have to be the same as the result type (which needs to be equal to op1
and op2's type).  Will test this and commit as obvious if it passes.

[Bug sanitizer/80403] UBSAN: compile time crash with "type mismatch in binary expression" message in / and % expr

2017-04-12 Thread babokin at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80403

--- Comment #8 from Dmitry Babokin  ---
Three errors in one test case. GCC r246882.

> cat f.cpp
extern const long long int var_7;
extern unsigned long int var_59;
int foo() {
  int a = (0 - 40U <= (0 == 8)) << !var_59 << (0 < var_7) == 0;
  int b = ((0 ^ 0) < long(1066066618772207110 <= 0)) / 0 << 0;
  return a+b;
}

> g++ -w -fsanitize=undefined -O0 -c f.cpp
f.cpp: In function ‘int foo()’:
f.cpp:3:5: error: mismatching comparison operand types
 int foo() {
 ^~~
unsigned int
int
_4 = D.2761 < 0;
f.cpp:3:5: error: type mismatch in shift expression
int
unsigned int
int
_19 = D.2761 << _18;
f.cpp:3:5: error: type mismatch in binary expression
int

long int

int

D.2772 = 0 / 0;
f.cpp:3:5: internal compiler error: verify_gimple failed

[Bug sanitizer/80403] UBSAN: compile time crash with "type mismatch in binary expression" message in / and % expr

2017-04-12 Thread babokin at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80403

--- Comment #7 from Dmitry Babokin  ---
80404 and 80405 seemed similar, but different to me, so I decided to report
them separately. Anyway, after the latest fixes I still see 2 compile crashes.
I'm reducing them and will report here.

[Bug sanitizer/80403] UBSAN: compile time crash with "type mismatch in binary expression" message in / and % expr

2017-04-12 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80403

Jakub Jelinek  changed:

   What|Removed |Added

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

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

[Bug sanitizer/80403] UBSAN: compile time crash with "type mismatch in binary expression" message in / and % expr

2017-04-12 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80403

--- Comment #5 from Jakub Jelinek  ---
Author: jakub
Date: Wed Apr 12 18:08:29 2017
New Revision: 246881

URL: https://gcc.gnu.org/viewcvs?rev=246881=gcc=rev
Log:
PR sanitizer/80403
PR sanitizer/80404
PR sanitizer/80405
* fold-const.c (fold_ternary_loc): Use op1 instead of arg1 as argument
to fold_build2_loc.  Convert TREE_OPERAND (tem, 0) to type.  Use
op0 instead of fold_convert_loc (loc, type, arg0).

* g++.dg/ubsan/pr80403.C: New test.
* g++.dg/ubsan/pr80404.C: New test.
* g++.dg/ubsan/pr80405.C: New test.

Added:
trunk/gcc/testsuite/g++.dg/ubsan/pr80403.C
trunk/gcc/testsuite/g++.dg/ubsan/pr80404.C
trunk/gcc/testsuite/g++.dg/ubsan/pr80405.C
Modified:
trunk/gcc/ChangeLog
trunk/gcc/fold-const.c
trunk/gcc/testsuite/ChangeLog

[Bug sanitizer/80403] UBSAN: compile time crash with "type mismatch in binary expression" message in / and % expr

2017-04-12 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80403

--- Comment #4 from Jakub Jelinek  ---
*** Bug 80405 has been marked as a duplicate of this bug. ***

[Bug sanitizer/80403] UBSAN: compile time crash with "type mismatch in binary expression" message in / and % expr

2017-04-12 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80403

--- Comment #3 from Jakub Jelinek  ---
*** Bug 80404 has been marked as a duplicate of this bug. ***

[Bug sanitizer/80403] UBSAN: compile time crash with "type mismatch in binary expression" message in / and % expr

2017-04-12 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80403

Jakub Jelinek  changed:

   What|Removed |Added

  Attachment #41183|0   |1
is obsolete||

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

The other two PRs are dups of this, added those testcases to this patch.

[Bug sanitizer/80403] UBSAN: compile time crash with "type mismatch in binary expression" message in / and % expr

2017-04-12 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80403

--- Comment #1 from Jakub Jelinek  ---
Created attachment 41183
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=41183=edit
gcc7-pr80403.patch

Untested fix.

[Bug sanitizer/80403] UBSAN: compile time crash with "type mismatch in binary expression" message in / and % expr

2017-04-11 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80403

Jakub Jelinek  changed:

   What|Removed |Added

 Status|UNCONFIRMED |ASSIGNED
   Last reconfirmed||2017-04-12
   Assignee|unassigned at gcc dot gnu.org  |jakub at gcc dot gnu.org
 Ever confirmed|0   |1