IBM Support

IJ04416: POINTER DEREFERENCE CONDITIONAL IN LOOP CAUSING BAD OUTPUT

Subscribe to this APAR

By subscribing, you receive periodic emails alerting you to the status of the APAR, along with a link to the fix after it becomes available. You can track this item individually or track all items by product.

Notify me when this APAR changes.

Notify me when an APAR for this component changes.

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

    IJ04416

  • Reported component name

    XL C FOR AIX

  • Reported component ID

    5725C7100

  • Reported release

    D10

  • Status

    CLOSED PER

  • PE

    NoPE

  • HIPER

    NoHIPER

  • Special Attention

    NoSpecatt / Xsystem

  • Submitted date

    2018-03-01

  • Closed date

    2018-03-01

  • Last modified date

    2018-03-01

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

    IV97267

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

Fix information

  • Fixed component name

    XL C FOR AIX

  • Fixed component ID

    5725C7100

Applicable component levels



Document information

More support for: XL C for AIX
Compiler

Software version: 13.1

Reference #: IJ04416

Modified date: 01 March 2018