[Bug middle-end/56917] -ftrapv detects a overflow wrongly.

2015-06-18 Thread rguenth at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56917

--- Comment #8 from Richard Biener rguenth at gcc dot gnu.org ---
This also fixed a rejects-valid

int lValue;
int main()
{
  switch (lValue)
{
case -(int)((2U  (8 * sizeof(int) - 2)) - 1) - 1:;
}
}

 g++-4.8 cMinLongValue.ii 
cMinLongValue.ii: In function ‘int main()’:
cMinLongValue.ii:6:54: error: overflow in constant expression [-fpermissive]
 case -(int)((2U  (8 * sizeof(int) - 2)) - 1) - 1:;
  ^
cMinLongValue.ii:6:54: error: overflow in constant expression [-fpermissive]

I am going to backport and add this testcase.

[Bug middle-end/56917] -ftrapv detects a overflow wrongly.

2015-06-18 Thread rguenth at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56917

--- Comment #9 from Richard Biener rguenth at gcc dot gnu.org ---
Author: rguenth
Date: Thu Jun 18 14:47:18 2015
New Revision: 224617

URL: https://gcc.gnu.org/viewcvs?rev=224617root=gccview=rev
Log:
2015-06-18  Richard Biener  rguent...@suse.de

Backport from mainline
2014-12-04  Marek Polacek  pola...@redhat.com

PR middle-end/56917
* fold-const.c (fold_unary_loc): Perform the negation in A's type
when transforming ~ (A - 1) or ~ (A + -1) to -A.

* g++.dg/other/const4.C: New testcase.

Added:
branches/gcc-4_8-branch/gcc/testsuite/g++.dg/other/const4.C
Modified:
branches/gcc-4_8-branch/gcc/ChangeLog
branches/gcc-4_8-branch/gcc/fold-const.c
branches/gcc-4_8-branch/gcc/testsuite/ChangeLog


[Bug middle-end/56917] -ftrapv detects a overflow wrongly.

2015-03-11 Thread mpolacek at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56917

--- Comment #7 from Marek Polacek mpolacek at gcc dot gnu.org ---
Author: mpolacek
Date: Wed Mar 11 10:37:38 2015
New Revision: 221346

URL: https://gcc.gnu.org/viewcvs?rev=221346root=gccview=rev
Log:
Backported from mainline
2014-12-04  Marek Polacek  pola...@redhat.com

PR middle-end/56917
* fold-const.c (fold_unary_loc): Perform the negation in A's type
when transforming ~ (A - 1) or ~ (A + -1) to -A.

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

Added:
branches/gcc-4_9-branch/gcc/testsuite/c-c++-common/ubsan/pr56917.c
Modified:
branches/gcc-4_9-branch/gcc/ChangeLog
branches/gcc-4_9-branch/gcc/fold-const.c
branches/gcc-4_9-branch/gcc/testsuite/ChangeLog


[Bug middle-end/56917] -ftrapv detects a overflow wrongly.

2014-12-04 Thread mpolacek at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56917

--- Comment #5 from Marek Polacek mpolacek at gcc dot gnu.org ---
Author: mpolacek
Date: Thu Dec  4 19:20:12 2014
New Revision: 218395

URL: https://gcc.gnu.org/viewcvs?rev=218395root=gccview=rev
Log:
PR middle-end/56917
* fold-const.c (fold_unary_loc): Perform the negation in A's type
when transforming ~ (A - 1) or ~ (A + -1) to -A.

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

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


[Bug middle-end/56917] -ftrapv detects a overflow wrongly.

2014-12-04 Thread mpolacek at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56917

Marek Polacek mpolacek at gcc dot gnu.org changed:

   What|Removed |Added

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

--- Comment #6 from Marek Polacek mpolacek at gcc dot gnu.org ---
Fixed.


[Bug middle-end/56917] -ftrapv detects a overflow wrongly.

2014-12-03 Thread mpolacek at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56917

Marek Polacek mpolacek at gcc dot gnu.org changed:

   What|Removed |Added

 Status|NEW |ASSIGNED
   Assignee|unassigned at gcc dot gnu.org  |mpolacek at gcc dot 
gnu.org

--- Comment #2 from Marek Polacek mpolacek at gcc dot gnu.org ---
Looking into this again.


[Bug middle-end/56917] -ftrapv detects a overflow wrongly.

2014-12-03 Thread mpolacek at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56917

Marek Polacek mpolacek at gcc dot gnu.org changed:

   What|Removed |Added

   Target Milestone|5.0 |4.8.4

--- Comment #3 from Marek Polacek mpolacek at gcc dot gnu.org ---
Adjusting target.  Happens with 4.8 as well.


[Bug middle-end/56917] -ftrapv detects a overflow wrongly.

2014-12-03 Thread rguenth at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56917

--- Comment #4 from Richard Biener rguenth at gcc dot gnu.org ---
fold looks too much through sign-changing NOP conversions, this makes it
tricky to spot errors in patterns.