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; 3+ 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] 3+ 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; 3+ 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] 3+ 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; 3+ 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] 3+ messages in thread

end of thread, other threads:[~2005-08-22 19:52 UTC | newest]

Thread overview: 3+ 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

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).