IBM Support

LI78225: IPA CAUSING INCORRECT POINTER ARITHMETIC

Subscribe

You can track all active APARs for this component.

 

APAR status

  • Closed as program error.

Error description

  • When compiling with -qipa=level=0, certain pointer arithmetic is
    done incorrectly.  The result could be incorrect output or
    incorrect memory access.
    
    
       === EXAMPLE ===
    
    int func(mystruct *obj, char *bp, int copy)
    {
          char *pstart = bp;
          if (copy)
          {
                obj->val1 = (*(unsigned int *)bp); bp += 4;
                obj->val2 = (*(unsigned int *)bp); bp += 4;
          }
          else
          {
                bp += 8;
          }
          return (bp - pstart);
    }
    
    The bp pointer is only incremented by (4+4)=8, leaving
    (bp - pstart)=8, but for the code generated, the value of pstart
    used in the subtraction (in gr0) has been incremented by 4**,
    which ends up giving (bp+8)-(pstart+4)=4, when the return result
    should be 8:
    
         | 000000                       PDEF func
        0|                              PROC obj,bp,copy,gr3-gr5
        6| 000080 cmpwi    2C050000 1 C4   cr0=gr5,0
    **  8| 000084 addi     38040004 1 AI   gr0=gr4,4
        6| 000088 bc       41820020 1 BT   CL.2,cr0,0x4/eq
        8| 00008C lwz      80A40000 1 L4A  gr5=(*)uint.rns0.(gr4,0)
        9| 000090 lwz      80C40004 1 L4A  gr6=(*)uint.rns0.(gr4,4)
        9| 000094 addi     38840008 1 AI   gr4=gr4,8
        8| 000098 stw      90A30000 1 ST4A
                        (*)mystruct.mystruct.val1.rns1.(gr3,0)=gr5
        9| 00009C stw      90C30004 1 ST4A
                        (*)mystruct.mystruct.val2.rns2.(gr3,4)=gr6
       15| 0000A0 subf     7C602050 1 S    gr3=gr4,gr0
        0| 0000A4 bclr     4E800020 1 BA   lr
        9|                       CL.2:
       13| 0000A8 addi     38040008 1 AI   gr0=gr4,8
       15| 0000AC subf     7C640050 1 S    gr3=gr0,gr4
       16| 0000B0 bclr     4E800020 1 BA   lr
    

Local fix

  • Do not use -qipa
    

Problem summary

  • PROBLEM DESCRIPTION:
    An incorrect runtime value is calculated by an internal code
    optimization.
    
    USERS AFFECTED:
    Any users of -qipa, or any options that imply -qipa (for
    example, -qpdf1).
    

Problem conclusion

  • The optimization was corrected, and IPA now generates correct
    code giving correct runtime values.
    

Temporary fix

Comments

APAR Information

  • APAR number

    LI78225

  • Reported component name

    XL C/C++ FOR LI

  • Reported component ID

    5725C7300

  • Reported release

    D10

  • Status

    CLOSED PER

  • PE

    NoPE

  • HIPER

    NoHIPER

  • Special Attention

    NoSpecatt

  • Submitted date

    2014-10-30

  • Closed date

    2014-10-30

  • Last modified date

    2014-10-30

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

    IV58760

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

Fix information

  • Fixed component name

    XL C/C++ FOR LI

  • Fixed component ID

    5725C7300

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":"13.1","Line of Business":{"code":"LOB57","label":"Power"}}]

Document Information

Modified date:
17 October 2021