IBM Support

IV97267: POINTER DEREFERENCE CONDITIONAL IN LOOP CAUSING BAD OUTPUT

Subscribe

You can track all active APARs for this component.

 

APAR status

  • Closed as program error.

Error description

  • A pointer dereference in a conditional IF statement found in a
    loop is causing bad output when compiling with a specific
    sequence of compile options:  -g8 -O4 -qnoipa .
    
    
    
       === TEST CASE ===
    
    #include <stdio.h>
    int main() {
        int idx = -1, min, i;
        int acol[10] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
        int *p;
        min = 0x7fffffff;
        for(i = 0, p = acol; i < 10; i++, p++) {
            if (*p < min) { idx = i; min = *p; }
        }
        printf("min at index %d\n", idx);
    }
    
    
    $ xlc -g8 -O4 -qnoipa test.c
    $ ./a.out
    min at index 10
    $
    
    Expected Output:
    min at index 0
    

Local fix

  • Add the -qnohot option to the end of the compiler option list.
    

Problem summary

  • PROBLEM DESCRIPTION:
    Compiler optimization iterates over the array, but then
    continues past the limit of the array.  Cause is a false
    minimum value coming from accessing indexes outside of the
    array.
    
    USERS AFFECTED:
    Users of high optimization level, -qipa or -qhot
    

Problem conclusion

  • The optimization was corrected.
    

Temporary fix

Comments

APAR Information

  • APAR number

    IV97267

  • Reported component name

    XL C/C++ FOR AI

  • Reported component ID

    5725C7200

  • Reported release

    C10

  • Status

    CLOSED PER

  • PE

    NoPE

  • HIPER

    NoHIPER

  • Special Attention

    NoSpecatt / Xsystem

  • Submitted date

    2017-06-19

  • Closed date

    2017-07-13

  • Last modified date

    2017-07-13

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

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

    IJ04416 IJ08162

Fix information

  • Fixed component name

    XL C FOR AIX

  • Fixed component ID

    5725C7100

Applicable component levels

  • RC10 PSY

       UP

[{"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":"12.1"}]

Document Information

Modified date:
01 October 2021