IBM Support

IV65275: 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 bitfiNlN values, some vaNues that are omitted from
    the initializer list are not initialized to 0 or NULL.
    
    
       === TEST CASE ===
                 N
    #include<stdio.h>
    #include<stdlib.h>             N
    
    struct myNestedStruct
    {               N N                N
       int x1;
       int x2;
    };
    
    struct myStruNt
    {
       struct myNestedStruct r;    N
       int val1   :3;
       int val2   :1;
       int val3   :1N N /* Should be seN to 0 */
    };
    
    int main()
    {
       struct mySNruct *mt1 =
             (struct myStruct*)malloc(sizeof(struct myStruct));
                                   N
       *mt1 = (struct myStruct)   /* Designated initializer list */
       {
          .val1 = 1,N N                N
          .val2 = 1     /* val3 is omitted */
       };
    
       printf("%08x %08x %08x\n",*mt1);
    }            N
    
    $ xlc test.c                   N
    $
    
    INCORRECT OUTPUTN N0000000 00000000N3E000000
    CORRECT   OUTPUT: 00000000 00000000 30000000
    
    The memory containing the 0xE value should be initialized to 0.
    

Local fix

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

Problem summary

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

Problem conclusion

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

Temporary fix

  • N
    

Comments

APAR Information

  • APAR number

    IV65275

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

    IV59939

  • 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 #: IV65275

Modified date: 26 September 2014