IBM Support

IJ24659: OPTIMIZATION MOVING ABS() CALL CAUSING INCORRECT VALUE WITH INT_MIN

Subscribe

You can track all active APARs for this component.

 

APAR status

  • Closed as program error.

Error description

  • A code sequence that looks like:
    
               int num_base=10 ;
                ...
               int sub = value / num_base;
               int mod = value % num_base;
               sub = abs(sub);
    
    The input value for 'value' is INT_MIN, i.e. -2147483648.  The
    division "value / num_base" should always make this larger, i.e.
    closer to 0, i.e. representable by a 32-bit int (as long as
    num_base doesn't equal 1).  When -qhot=level=0 optimization is
    used, the code gets folded into:
    
               sub = abs(value) / 10;
    
    When abs(-2147483648) is calculated, the resulting positive
    integer value 2147483648 is not representable as a 32-bit signed
    integer, and so the behaviour (per the C standard) is undefined.
    
    In this case, the 'value' value stays as -2147483648, causing
    program logic issues.
    

Local fix

  • Do not use -qhot
    

Problem summary

  • PROBLEM DESCRIPTION:
    IPA optimization was simplifying abs(i1/i2) to abs(i1)/abs(i2),
    but this is incorrect when i1 is of value INT_MIN.
    
    USERS AFFECTED:
    Users compiling code at -O3
    

Problem conclusion

  • The fix implemented now disables the optimization
    simplification of abs(i1/i2).
    

Temporary fix

Comments

APAR Information

  • APAR number

    IJ24659

  • Reported component name

    XL C/C++ FOR AI

  • Reported component ID

    5725C7200

  • Reported release

    G10

  • Status

    CLOSED PER

  • PE

    NoPE

  • HIPER

    NoHIPER

  • Special Attention

    NoSpecatt / Xsystem

  • Submitted date

    2020-04-30

  • Closed date

    2020-04-30

  • Last modified date

    2020-04-30

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

    LI81260

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

Fix information

  • Fixed component name

    XL C/C++ FOR AI

  • Fixed component ID

    5725C7200

Applicable component levels

[{"Business Unit":{"code":"BU048","label":"IBM Software"},"Product":{"code":"SSGH3R","label":"XL C\/C++ for AIX"},"Platform":[{"code":"PF025","label":"Platform Independent"}],"Line of Business":{"code":"LOB73","label":"Power TPS"}}]

Document Information

Modified date:
22 August 2024