IBM Support

LI75537: INCORRECT RESULT WITH -O2

Subscribe

You can track all active APARs for this component.

 

APAR status

  • Closed as program error.

Error description

  • The following test case produces incorrect result if compiled
    with -O2.
    
    
    ==========
    TEST CASE:
    ==========
    
    #include <stdio.h>
    int main()
         {
         double d = 1.0;
         short i;
         struct DBLM { double d;};
         union {
            struct DBLM a[2];
            struct { struct DBLM low, by; } s;
            } du;
         for(i=0;i<2;i++)
            du.a[i].d = d;
         if(du.s.by.d == 0)
            printf("ERROR: Should not get here! %g\n",du.s.by.d);
         return 0;
         }
    
    
    
    BAD:
    
    $xlc_r ./t.c -O2
    $./a.out
    ERROR: Should not get here! 0
    
    GOOD:
    xlc_r ./t.c
    $./a.out
    (prints out nothing)
    

Local fix

  • Use XL C/C++ for AIX release prior to V10.1.
    

Problem summary

  • PROBLEM DESCRIPTION: Incorrect result with -O2.  The compiler
    does not always alias array and nested struct members of an
    Union together.  This causes a correctness problem at
    Optimization.
    
    USERS AFFECTED: C only.  All platforms.  Nested array and
    struct members within a union.
    

Problem conclusion

  • The compiler now properly recognizing that an element of an
    array member and a member of a sub-struct member of a union
    overlap the same memory location. The problem is fixed.
    

Temporary fix

Comments

APAR Information

  • APAR number

    LI75537

  • Reported component name

    XL C/C++ RHEL52

  • Reported component ID

    5724U8310

  • Reported release

    A10

  • Status

    CLOSED PER

  • PE

    NoPE

  • HIPER

    NoHIPER

  • Special Attention

    NoSpecatt

  • Submitted date

    2010-07-28

  • Closed date

    2010-07-28

  • Last modified date

    2010-07-28

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

    IZ74157

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

Fix information

  • Fixed component name

    XL C/C++ RHEL52

  • Fixed component ID

    5724U8310

Applicable component levels

[{"Business Unit":{"code":"BU054","label":"Systems w\/TPS"},"Product":{"code":"SSJT9L","label":"XL C\/C++"},"Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"A.1","Line of Business":{"code":"LOB08","label":"Cognitive Systems"}}]

Document Information

Modified date:
17 October 2021