[LLVMbugs] [Bug 23705] New: Different result (integer wrap) by optimization setting

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Sat May 30 00:52:33 PDT 2015


https://llvm.org/bugs/show_bug.cgi?id=23705

            Bug ID: 23705
           Summary: Different result (integer wrap) by optimization
                    setting
           Product: tools
           Version: 3.5
          Hardware: Macintosh
                OS: MacOS X
            Status: NEW
          Severity: normal
          Priority: P
         Component: llvm-gcc
          Assignee: unassignedbugs at nondot.org
          Reporter: HHG01200 at nifty.ne.jp
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

On Mac OS X 10.10.3, Apple LLVM 6.0, with no optimization (-O0) or -O1, print
"A" (expected result).
However, with optimization (-Os), print "B" (not expected result).


file 1
-------------------
#include    <stdio.h>

extern    int    GetA();
extern    int    GetB();
extern    int    GetC();

int    main()
{
    int    a = GetA();
    int    c = GetC();
    int    d = GetB() - c;

    if ((a - c) < (d))
    {
        puts("A");
    }
    else
    {
        puts("B");
    }
    return 0;
}
-------------------


file 2
-------------------
#include    <limits.h>

int    GetA()
{
    return INT_MAX;
}

int    GetB()
{
    return INT_MIN;
}

int    GetC()
{
    return INT_MAX / 2;
}
-------------------

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20150530/92c0c4d5/attachment.html>


More information about the llvm-bugs mailing list