IBM Support

IZ91166: INCORRECT OUT WITH -O2 -Q64

Fixes are available

May 2011 PTF for XL C for AIX, V11.1
May 2011 PTF for XL C/C++ for AIX, V11.1
August 2011 PTF for XL C/C++ for AIX, V11.1
November 2011 PTF for XL C/C++ for AIX, V11.1
January 2012 PTF for XL C for AIX, V11.1
January 2012 PTF for XL C/C++ for AIX, V11.1
April 2012 PTF for XL C for AIX, V11.1
April 2012 PTF for XL C/C++ for AIX, V11.1
July 2012 PTF for XL C/C++ for AIX, V11.1
October 2012 PTF for XL C for AIX, V11.1
October 2012 PTF for XL C/C++ for AIX, V11.1
February 2013 PTF for XL C for AIX, V11.1
February 2013 PTF for XL C/C++ for AIX, V11.1
XL C/C++ for AIX Fix Pack 14 (May 2013 PTF) for 11.1
XL C for AIX Fix Pack 14 (May 2013 PTF) for 11.1
XL C/C++ for AIX Fix Pack 15 (August 2013 PTF) for 11.1
XL C for AIX Fix Pack 15 (August 2013 PTF) for 11.1
XL C/C++ for AIX Fix Pack 16 (November 2013 PTF) for 11.1
XL C for AIX Fix Pack 17 (February 2014 PTF) for 11.1
XL C/C++ for AIX Fix Pack 17 (February 2014 PTF) for 11.1
XL C/C++ for AIX Fix Pack 18 (May 2014 PTF) for 11.1
XL C/C++ for AIX Fix Pack 19 (August 2014 PTF) for 11.1
XL C/C++ for AIX Fix Pack 20 (November 2014 PTF) for 11.1
XL C for AIX Fix Pack 21 (April 2015 PTF) for 11.1
XL C/C++ for AIX Fix Pack 21 (April 2015 PTF) for 11.1
XL C/C++ for AIX Fix Pack 22 (September 2015 PTF) for 11.1
XL C for AIX Fix Pack 23 (March 2016 PTF) for 11.1
XL C/C++ for AIX Fix Pack 23 (March 2016 PTF) for 11.1
XL C for AIX Fix Pack 24 (September 2016 PTF) for 11.1
XL C/C++ for AIX Fix Pack 24 (September 2016 PTF) for 11.1
August 2011 PTF for XL C for AIX, V11.1
November 2011 PTF for XL C for AIX, V11.1
July 2012 PTF for XL C for AIX, V11.1
XL C for AIX Fix Pack 16 (November 2013 PTF) for 11.1
XL C for AIX Fix Pack 18 (May 2014 PTF) for 11.1
XL C for AIX Fix Pack 19 (August 2014 PTF) for 11.1
XL C for AIX Fix Pack 20 (November 2014 PTF) for 11.1
XL C for AIX Fix Pack 22 (September 2015 PTF) for 11.1

Subscribe

You can track all active APARs for this component.

 

APAR status

  • Closed as program error.

Error description

  • Incorrect output is generated when a test case is compiled with
    -O2 -q64.
    
    ===== Test Case
    test.c
    
    int foo() { return 0; }
    
    int bar(int *p)
    {
        int rc;
    
        rc = foo();
        if (rc < 0)
           return rc;
    
        p[0] = 0;
        p[1] = 0x8000;
        return 0;
    }
    
    #include <stdio.h>
    
    int main()
    {
       int rc, x[2];
    
       rc = bar(x);
       printf("rc %d\n", rc);
       return 0;
    }
    
    ====== Observed Output
    # xlc_r -q64 -O0 test.c && a.out
    rc 0
    # xlc_r -q64 -O2 test.c && a.out
    rc 32768                             <== Incorrect
    # xlc_r -q64 -O3 test.c && a.out
    rc 0
    # xlc_r -q64 -O4 test.c && a.out
    rc 0
    # xlc_r -q64 -O5 test.c && a.out
    rc 0
    

Local fix

  • The test case passes when compiled at all optimization levels,
    except for -O2. In addition, the test case also passed when
    compiled with -q32 or -qarch=pwr5 or lower.
    

Problem summary

  • PROBLEM DESCRIPTION:
    An internal function returns incorrect instructions, which
    makes other optimization discard it, hence leading to wrong
    code.
    
    USERS AFFECTED:
    Users of code (1) containing functions whose return can be
    optimized and (2) contains optimization opportunities and (3)
    is compiled at O2 q64.
    

Problem conclusion

  • This problem was here from the beginning of the optimization
    routine, it was just exposed recently by the extra step which
    triggered dead code. The fix is straightforward.
    

Temporary fix

Comments

APAR Information

  • APAR number

    IZ91166

  • Reported component name

    XL C/C++ AIX

  • Reported component ID

    5724X1300

  • Reported release

    B10

  • Status

    CLOSED PER

  • PE

    NoPE

  • HIPER

    NoHIPER

  • Special Attention

    NoSpecatt

  • Submitted date

    2010-12-16

  • Closed date

    2011-03-08

  • Last modified date

    2011-03-08

  • APAR is sysrouted FROM one or more of the following:

  • APAR is sysrouted TO one or more of the following:

    LI76111

Fix information

  • Fixed component name

    XL C FOR AIX

  • Fixed component ID

    5724X1200

Applicable component levels

[{"Line of Business":{"code":"LOB57","label":"Power"},"Business Unit":{"code":"BU058","label":"IBM Infrastructure w\/TPS"},"Product":{"code":"SSGH2K","label":"XL C for AIX"},"Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"11.1"}]

Document Information

Modified date:
06 October 2021