Bug 80405 - UBSAN: compile time crash with "type mismatch in shift expression" error
Summary: UBSAN: compile time crash with "type mismatch in shift expression" error
Status: RESOLVED DUPLICATE of bug 80403
Alias: None
Product: gcc
Classification: Unclassified
Component: sanitizer (show other bugs)
Version: 7.0
: P3 normal
Target Milestone: ---
Assignee: Jakub Jelinek
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-04-11 23:42 UTC by Dmitry Babokin
Modified: 2017-04-12 18:09 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2017-04-12 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dmitry Babokin 2017-04-11 23:42:46 UTC
gcc x86_64, top of the trunk.

> cat f.cpp
extern unsigned int var_60, var_110;
void foo() {
    var_110 = (!~0 >= unsigned(0 < 0)) << var_60;
}

> g++ -fsanitize=undefined -w -O0 -c f.cpp
f.cpp: In function ‘void foo()’:
f.cpp:2:6: error: type mismatch in shift expression
 void foo() {
      ^~~
int
unsigned int
unsigned int
_2 = 1 << var_60.0;
f.cpp:2:6: internal compiler error: verify_gimple failed
<...>
Comment 1 Jakub Jelinek 2017-04-12 07:11:29 UTC
Dup.

*** This bug has been marked as a duplicate of bug 80403 ***
Comment 2 Jakub Jelinek 2017-04-12 18:09:07 UTC
Author: jakub
Date: Wed Apr 12 18:08:29 2017
New Revision: 246881

URL: https://gcc.gnu.org/viewcvs?rev=246881&root=gcc&view=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