IBM Support

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

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 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

    LI81260

  • Reported component name

    XL C/C++ LINUX

  • Reported component ID

    5725C7310

  • Reported release

    G11

  • Status

    CLOSED PER

  • PE

    NoPE

  • HIPER

    NoHIPER

  • Special Attention

    NoSpecatt / Xsystem

  • Submitted date

    2020-03-05

  • Closed date

    2020-03-11

  • Last modified date

    2020-03-11

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

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

    IJ24659

Fix information

  • Fixed component name

    XL C/C++ LINUX

  • Fixed component ID

    5725C7310

Applicable component levels

[{"Business Unit":{"code":"BU053","label":"Cloud & Data Platform"},"Product":{"code":"SSXVZZ","label":"XL C\/C++ for Linux"},"Platform":[{"code":"PF025","label":"Platform Independent"}],"Line of Business":{"code":"LOB17","label":"Mainframe TPS"}}]

Document Information

Modified date:
01 May 2020