IBM Support

IV61469: STRUCT INITIALIZER LIST FOR BITFIELDS NOT INITIALIZING OMITTED MEMBERS TO NULL

Subscribe

You can track all active APARs for this component.

 

APAR status

  • Closed as program error.

Error description

  • When using a designated initializer list to initialize a struct
    containing bitfield values, some values that are omitted from
    the initializer list are not initialized to 0 or NULL.
    
    
       === TEST CASE ===
    
    #include<stdio.h>
    #include<stdlib.h>
    
    struct myNestedStruct
    {
       int x1;
       int x2;
    };
    
    struct myStruct
    {
       struct myNestedStruct r;
       int val1   :3;
       int val2   :1;
       int val3   :1;   /* Should be set to 0 */
    };
    
    int main()
    {
       struct myStruct *mt1 =
             (struct myStruct*)malloc(sizeof(struct myStruct));
    
       *mt1 = (struct myStruct)   /* Designated initializer list */
       {
          .val1 = 1,
          .val2 = 1     /* val3 is omitted */
       };
    
       printf("%08x %08x %08x\n",*mt1);
    }
    
    $ xlc test.c
    $
    
    INCORRECT OUTPUT: 00000000 00000000 3E000000
    CORRECT   OUTPUT: 00000000 00000000 30000000
    
    The memory containing the 0xE value should be initialized to 0.
    

Local fix

  • Use memset to initialize the struct to NULL, then manually set
    the values via struct_name->var_name=<value> syntax.
    

Problem summary

  • PROBLEM DESCRIPTION:
    Uninitialized bitfields are not zero initialized in the
    presence of designated initializers.
    
    USERS AFFECTED:
    Users of the C compiler with uninitialized bitfields and
    designated initializers.
    

Problem conclusion

  • The C compiler was fixed such that uninitialized bitfields with
    neighbouring bitfields that are initialized with designated
    initializers will be zero initialized for auto local variables.
    

Temporary fix

Comments

APAR Information

  • APAR number

    IV61469

  • Reported component name

    XL C/C++ FOR AI

  • Reported component ID

    5725C7200

  • Reported release

    B10

  • Status

    CLOSED PER

  • PE

    NoPE

  • HIPER

    NoHIPER

  • Special Attention

    NoSpecatt

  • Submitted date

    2014-06-12

  • Closed date

    2014-07-30

  • Last modified date

    2014-08-19

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

    IV59939

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

Fix information

  • Fixed component name

    XL C FOR AIX

  • Fixed component ID

    5724X1200

Applicable component levels

[{"Business Unit":{"code":"BU058","label":"IBM Infrastructure w\/TPS"},"Product":{"code":"SSGH2K","label":"XL C for AIX"},"Component":"","ARM Category":[],"Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"11.1","Edition":"","Line of Business":{"code":"LOB57","label":"Power"}}]

Document Information

Modified date:
19 August 2014