public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug rtl-optimization/23518] New: some gcc optimizations do not take overflow into account
@ 2005-08-22 19:46 pterjan at gmail dot com
  2005-08-22 19:50 ` [Bug middle-end/23518] some gcc optimizations do not take overflow into account with -fwrapv pinskia at gcc dot gnu dot org
  2005-08-22 19:56 ` pinskia at gcc dot gnu dot org
  0 siblings, 2 replies; 8+ messages in thread
From: pterjan at gmail dot com @ 2005-08-22 19:46 UTC (permalink / raw)
  To: gcc-bugs

This has been tested on 3.3.6, 3.4.1 and 4.0.1

The following test is considered always false and the block is dropped but "a"
being "int", (a + 1 < 0) is true.

[pterjan@plop tmp]$ cat lim.c
#include <stdio.h>
#include <limits.h>

int main (void)
{
        int a = INT_MAX;
        if ((a < 0) || (a + 1 < 0)) {
                printf("Hello !\n");
        }
        return 0;
}
[pterjan@plop tmp]$ gcc -O0 lim.c ; ./a.out
Hello !
[pterjan@plop tmp]$ gcc -O1 lim.c ; ./a.out
[pterjan@plop tmp]$

-- 
           Summary: some gcc optimizations do not take overflow into account
           Product: gcc
           Version: 4.0.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: rtl-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: pterjan at gmail dot com
                CC: gcc-bugs at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23518


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug middle-end/23518] some gcc optimizations do not take overflow into account with -fwrapv
  2005-08-22 19:46 [Bug rtl-optimization/23518] New: some gcc optimizations do not take overflow into account pterjan at gmail dot com
@ 2005-08-22 19:50 ` pinskia at gcc dot gnu dot org
  2005-08-22 19:56 ` pinskia at gcc dot gnu dot org
  1 sibling, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-08-22 19:50 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-08-22 19:45 -------
Note signed overflow is undefined unless you use -fwrapv except that does not fix this.

This is a bug in fold, most likely build_range_check. 

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
          Component|rtl-optimization            |middle-end
     Ever Confirmed|                            |1
           Keywords|                            |wrong-code
      Known to fail|                            |3.4.0 4.0.0 4.1.0
   Last reconfirmed|0000-00-00 00:00:00         |2005-08-22 19:45:50
               date|                            |
            Summary|some gcc optimizations do   |some gcc optimizations do
                   |not take overflow into      |not take overflow into
                   |account                     |account with -fwrapv


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23518


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug middle-end/23518] some gcc optimizations do not take overflow into account with -fwrapv
  2005-08-22 19:46 [Bug rtl-optimization/23518] New: some gcc optimizations do not take overflow into account pterjan at gmail dot com
  2005-08-22 19:50 ` [Bug middle-end/23518] some gcc optimizations do not take overflow into account with -fwrapv pinskia at gcc dot gnu dot org
@ 2005-08-22 19:56 ` pinskia at gcc dot gnu dot org
  1 sibling, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-08-22 19:56 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-08-22 19:52 -------
Here is a java program (since -fwrapv is turned on by default for java front-end unlike the C front-end 
since it is undefined in C and defined in java):
class t
{
  public static void main(String as[])
  {
    int a;
    a = Integer.MAX_VALUE;
    if ((a < 0) || (a + 1 < 0))  {
      System.out.println("Hello");
    }
  }
}

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23518


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug middle-end/23518] some gcc optimizations do not take overflow into account with -fwrapv
       [not found] <bug-23518-10629@http.gcc.gnu.org/bugzilla/>
                   ` (3 preceding siblings ...)
  2005-12-22  4:04 ` kazu at gcc dot gnu dot org
@ 2005-12-22  4:06 ` kazu at gcc dot gnu dot org
  4 siblings, 0 replies; 8+ messages in thread
From: kazu at gcc dot gnu dot org @ 2005-12-22  4:06 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from kazu at gcc dot gnu dot org  2005-12-22 04:06 -------
Oops, I forgot to change resolution to FIXED.


-- 

kazu at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23518


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug middle-end/23518] some gcc optimizations do not take overflow into account with -fwrapv
       [not found] <bug-23518-10629@http.gcc.gnu.org/bugzilla/>
                   ` (2 preceding siblings ...)
  2005-12-22  4:03 ` kazu at gcc dot gnu dot org
@ 2005-12-22  4:04 ` kazu at gcc dot gnu dot org
  2005-12-22  4:06 ` kazu at gcc dot gnu dot org
  4 siblings, 0 replies; 8+ messages in thread
From: kazu at gcc dot gnu dot org @ 2005-12-22  4:04 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from kazu at gcc dot gnu dot org  2005-12-22 04:04 -------
Just checked in a patch.


-- 

kazu at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |4.2.0


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23518


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug middle-end/23518] some gcc optimizations do not take overflow into account with -fwrapv
       [not found] <bug-23518-10629@http.gcc.gnu.org/bugzilla/>
  2005-11-28 16:28 ` pinskia at gcc dot gnu dot org
  2005-12-20 19:58 ` kazu at gcc dot gnu dot org
@ 2005-12-22  4:03 ` kazu at gcc dot gnu dot org
  2005-12-22  4:04 ` kazu at gcc dot gnu dot org
  2005-12-22  4:06 ` kazu at gcc dot gnu dot org
  4 siblings, 0 replies; 8+ messages in thread
From: kazu at gcc dot gnu dot org @ 2005-12-22  4:03 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from kazu at gcc dot gnu dot org  2005-12-22 04:03 -------
Subject: Bug 23518

Author: kazu
Date: Thu Dec 22 04:03:32 2005
New Revision: 108940

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=108940
Log:
gcc/
        PR tree-optimization/23518
        * fold-const.c (make_range): Don't move a constant to the
        other side of the comparison if the type is signed and -fwrapv
        is given.

gcc/testsuite/
        PR tree-optimization/23518
        * testsuite/gcc.dg/pr23518.c: New.

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


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23518


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug middle-end/23518] some gcc optimizations do not take overflow into account with -fwrapv
       [not found] <bug-23518-10629@http.gcc.gnu.org/bugzilla/>
  2005-11-28 16:28 ` pinskia at gcc dot gnu dot org
@ 2005-12-20 19:58 ` kazu at gcc dot gnu dot org
  2005-12-22  4:03 ` kazu at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 8+ messages in thread
From: kazu at gcc dot gnu dot org @ 2005-12-20 19:58 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from kazu at gcc dot gnu dot org  2005-12-20 19:58 -------
I've got a patch.


-- 

kazu at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |kazu at gcc dot gnu dot org
                   |dot org                     |
             Status|NEW                         |ASSIGNED
      Known to fail|3.4.0 4.0.0 4.1.0           |3.4.0 4.0.0 4.1.0 4.2.0


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23518


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug middle-end/23518] some gcc optimizations do not take overflow into account with -fwrapv
       [not found] <bug-23518-10629@http.gcc.gnu.org/bugzilla/>
@ 2005-11-28 16:28 ` pinskia at gcc dot gnu dot org
  2005-12-20 19:58 ` kazu at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-11-28 16:28 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from pinskia at gcc dot gnu dot org  2005-11-28 16:28 -------
fold_range_test is wrong, around fold-const.c:4635


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23518


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2005-12-22  4:06 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-08-22 19:46 [Bug rtl-optimization/23518] New: some gcc optimizations do not take overflow into account pterjan at gmail dot com
2005-08-22 19:50 ` [Bug middle-end/23518] some gcc optimizations do not take overflow into account with -fwrapv pinskia at gcc dot gnu dot org
2005-08-22 19:56 ` pinskia at gcc dot gnu dot org
     [not found] <bug-23518-10629@http.gcc.gnu.org/bugzilla/>
2005-11-28 16:28 ` pinskia at gcc dot gnu dot org
2005-12-20 19:58 ` kazu at gcc dot gnu dot org
2005-12-22  4:03 ` kazu at gcc dot gnu dot org
2005-12-22  4:04 ` kazu at gcc dot gnu dot org
2005-12-22  4:06 ` kazu at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).