[Bug middle-end/67338] fold-const sanitizer runtime error in roundup_loc

2017-03-21 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67338

--- Comment #6 from Jakub Jelinek  ---
(In reply to Vittorio Zecca from comment #5)
> I still have a similar issue in 7.0.1
> 
> ../../gcc-7-246252/gcc/fold-const.c:14253:11: runtime error: negation of
> -2147483648 cannot be represented in type 'int'; cast to an unsigned type to
> negate this value to itself
> 
> compiling
> 
> struct { __attribute__((aligned (1 << 28))) double a; };
> 
> fold-const.c:14253 is "val &= - (int) divisor;"
> 
> Should I open a new bug?

That code is no longer there, there is
  val &= (int) -divisor;
instead.  So no, you can't see this with current trunk.

[Bug middle-end/67338] fold-const sanitizer runtime error in roundup_loc

2017-03-21 Thread zeccav at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67338

--- Comment #5 from Vittorio Zecca  ---
I still have a similar issue in 7.0.1

../../gcc-7-246252/gcc/fold-const.c:14253:11: runtime error: negation of
-2147483648 cannot be represented in type 'int'; cast to an unsigned type to
negate this value to itself

compiling

struct { __attribute__((aligned (1 << 28))) double a; };

fold-const.c:14253 is "val &= - (int) divisor;"

Should I open a new bug?

[Bug middle-end/67338] fold-const sanitizer runtime error in roundup_loc

2017-03-21 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67338

Jakub Jelinek  changed:

   What|Removed |Added

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

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

[Bug middle-end/67338] fold-const sanitizer runtime error in roundup_loc

2017-03-21 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67338

--- Comment #3 from Jakub Jelinek  ---
Author: jakub
Date: Tue Mar 21 08:10:30 2017
New Revision: 246305

URL: https://gcc.gnu.org/viewcvs?rev=246305&root=gcc&view=rev
Log:
PR c/67338
* fold-const.c (round_up_loc): Negate divisor in unsigned type to
avoid UB.

* gcc.dg/pr67338.c: New test.

Added:
trunk/gcc/testsuite/gcc.dg/pr67338.c
Modified:
trunk/gcc/ChangeLog
trunk/gcc/fold-const.c
trunk/gcc/testsuite/ChangeLog

[Bug middle-end/67338] fold-const sanitizer runtime error in roundup_loc

2017-03-20 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67338

Jakub Jelinek  changed:

   What|Removed |Added

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

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

Untested fix.

[Bug middle-end/67338] fold-const sanitizer runtime error in roundup_loc

2017-03-19 Thread zeccav at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67338

--- Comment #1 from Vittorio Zecca  ---
Still in 7.0.1

../../gcc-7-246252/gcc/fold-const.c:14253:11: runtime error: negation of
-2147483648 cannot be represented in type 'int'; cast to an unsigned type to
negate this value to itself