backport: re PR c++/83713 (ICE in do_narrow at gcc/convert.c:474)

2018-01-09  Richard Biener  <rguenther@suse.de>

	Backport from mainline
	2018-01-08  Richard Biener  <rguenther@suse.de>

	PR middle-end/83713
	* convert.c (do_narrow): Properly guard TYPE_OVERFLOW_WRAPS checks.

	* g++.dg/torture/pr83713.C: New testcase.

From-SVN: r256371
This commit is contained in:
Richard Biener 2018-01-09 08:53:14 +00:00 committed by Richard Biener
parent 603ceb882d
commit d8d1029d8e
4 changed files with 32 additions and 2 deletions

View File

@ -1,3 +1,11 @@
2018-01-09 Richard Biener <rguenther@suse.de>
Backport from mainline
2018-01-08 Richard Biener <rguenther@suse.de>
PR middle-end/83713
* convert.c (do_narrow): Properly guard TYPE_OVERFLOW_WRAPS checks.
2018-01-08 Jim Wilson <jimw@sifive.com>
Backport from mainline

View File

@ -461,8 +461,10 @@ do_narrow (location_t loc,
type in case the operation in outprec precision
could overflow. Otherwise, we would introduce
signed-overflow undefinedness. */
|| ((!TYPE_OVERFLOW_WRAPS (TREE_TYPE (arg0))
|| !TYPE_OVERFLOW_WRAPS (TREE_TYPE (arg1)))
|| ((!(INTEGRAL_TYPE_P (TREE_TYPE (arg0))
&& TYPE_OVERFLOW_WRAPS (TREE_TYPE (arg0)))
|| !(INTEGRAL_TYPE_P (TREE_TYPE (arg1))
&& TYPE_OVERFLOW_WRAPS (TREE_TYPE (arg1))))
&& ((TYPE_PRECISION (TREE_TYPE (arg0)) * 2u
> outprec)
|| (TYPE_PRECISION (TREE_TYPE (arg1)) * 2u

View File

@ -1,3 +1,11 @@
2018-01-09 Richard Biener <rguenther@suse.de>
Backport from mainline
2018-01-08 Richard Biener <rguenther@suse.de>
PR middle-end/83713
* g++.dg/torture/pr83713.C: New testcase.
2018-01-08 Jim Wilson <jimw@sifive.com>
Backport from mainline

View File

@ -0,0 +1,12 @@
// { dg-do compile }
class a
{
char b;
void c ();
};
void
a::c ()
{
&b + ((long long) &b & 0);
}