IBM Support

LI76282: INCORRECT OUTPUT WITH -O3 AND -QLIBANSI

Subscribe

You can track all active APARs for this component.

 

APAR status

  • Closed as program error.

Error description

  • The following testcase produces incorrect output with "-O3
    -qlibansi":
    
    1. Testcase:
    
    /************ test.c ************/
    
    #include <stdio.h>
    
    void foo(void *ws) {
      *(int *)ws = 0;
    }
    
    int main()
    {
       int *            testInString;
       int *            testOutString;
       unsigned char    eq;
       testInString = (int *)malloc(6);
       testOutString = (int *)malloc(6);
       bzero(testInString,6);
       bzero(testOutString,6);
       memcpy(testInString,"HELLO",5);
       memcpy(testOutString,"HELLO",5);
       eq = (unsigned char)(!memcmp(testInString,testOutString,5));
       foo(testInString);
       if (!eq) printf("WRONG!!!! Should not print.\n");
       else printf("Correct!\n");
       return(1);
    
    }
    
    /******** end of test.c ***********/
    
    2. Compile with: xlc_r test.c -O3 -q64 -qlibansi
    
    3. Run:
    
    ./a.out
    
    
    Actual Output:
    
    WRONG!!!! Should not print.
    
    
    
    Expected output:
    
    Correct!
    

Local fix

  • 1. Lower optimization level from -O3 to -O2
    2. Do not use option -qlibansi
    

Problem summary

  • Incorrect code generation for memcmp operations with -O3 and
    -qlibansi
    

Problem conclusion

  • Fixed a case where memcmp calls could be optimized incorrectly
    with -qlibansi.
    

Temporary fix

Comments

APAR Information

  • APAR number

    LI76282

  • Reported component name

    XL C/C++ FOR LI

  • Reported component ID

    5724X1400

  • Reported release

    B10

  • Status

    CLOSED PER

  • PE

    NoPE

  • HIPER

    NoHIPER

  • Special Attention

    NoSpecatt / Xsystem

  • Submitted date

    2011-07-12

  • Closed date

    2011-07-12

  • Last modified date

    2011-07-12

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

    IZ95269

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

Fix information

  • Fixed component name

    XL C/C++ FOR LI

  • Fixed component ID

    5724X1400

Applicable component levels

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

Document Information

Modified date:
16 October 2021