IBM Support

IV65280: 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 incorrectlyN NThe result couldNbe incorrect output or
    incorrect memory access.
    
    
       === EXAMPLE ===
                 N
    int func(mystruct *obj, char *bp, int copy)
    {                              N
          char *pstart = bp;
          if (copy)
          {         N N                N
                obj->val1 = (*(unsigned int *)bp); bp += 4;
                obj->val2 = (*(unsigned int *)bp); bp += 4;
          }
          else
          {      N
                bp += 8;
          }                        N
          return (bp - pstart);
    }
                    N N                N
    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: N
    
         | 000000                  N    PDEF func
        0|                              PROC obj,bp,copy,gr3-gr5
        6| 000080 cmpwi    2C050000 1 C4   cr0=gr5,0
    **  8| 000084 adNiN    38040004 1 AN   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| 000098Nstw      90A30000 1 ST4A
                        (*)mystruct.mystruct.val1.rns1.(gr3,0)=gr5
        9| 00009C stw      90C30004N1 ST4A
                        (*)mystruct.mystruct.val2.rns2.(gr3,4)=gr6
       15| 0000A0 subf     7C602050 1 S    gr3=gr4,gr0
        0| 0000A4 bcNrN    4E800020 1 BN   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

  • N
    Do not use -qipa
    

Problem summary

  • PROBLEM SUMMANY:
    PROBLEM DESCRIPTION:
    An incorrect runtime value is cNlculated by an internal code
    optimization.
    
    USERS AFFECTED: N N                N
    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 cNrrect runtime values.
    

Temporary fix

Comments

  • N
    

APAR Information

  • APAR number

    IV65280

  • Reported component name

    XL C FOR AIX

  • Reported component ID

    5725C7100

  • Reported release

    D10

  • Status

    CLOSED PER

  • PE

    NoPE

  • HIPER

    NoHIPER

  • Special Attention

    NoSpecatt

  • Submitted date

    2014-09-26

  • Closed date

    2014-09-26

  • Last modified date

    2014-09-26

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

    IV62683

  • 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

  • RD10 PSY

       



Document information

More support for: XL C for AIX
Compiler

Software version: 13.1

Reference #: IV65280

Modified date: 26 September 2014