IBM Support

IZ32374: STRUCT PADDING BYTES NOT INIATILIZED

Subscribe

You can track all active APARs for this component.

 

APAR status

  • Closed as program error.

Error description

  • Structures have been initialized differently in C and C++ and
    this is causing a problem to user's application.
    
    ==== TESTCASE:
    
    
    #include <stdio.h>
    #include <string.h>
    #include <stdlib.h>
    
    struct mystruct
    {
      char c1;
      int i;
    };
    
    static void copy_struct(struct mystruct* pMystruct_temp1)
    {
      struct mystruct mystruct_stack = {0};
      *pMystruct_temp1 = mystruct_stack;
      memset(&mystruct_stack,255,sizeof(struct mystruct));
    }
    
    int main(int argc, char** argv)
    {
      struct mystruct struct1;
      struct mystruct struct2;
      memset(&struct1,0,sizeof(struct mystruct));
      memset(&struct2,0,sizeof(struct mystruct));
      copy_struct(&struct1);
      copy_struct(&struct2);
    
      if(memcmp(&struct1,&struct2,sizeof(struct mystruct)))  /*
    where the
    dbx display is one*/
         printf("these structs are different\n");
      else
         printf("these structs are equal\n");
    
      return 0;
    }
    
    ===== ACTUAL OUTPUT:
    C:   these structures are equal
    C++: thes structures are not equal
    
    ===== EXPECTED OUTPUT:
    REQUIRED, FREEFORM
    C++: Struct should be initialized to null and the output should
    be: these structues are equal.
    

Local fix

  • Use -qinitauto
    

Problem summary

  • The C++ compiler does not zero fill pad bytes between struct
    members when initialized using braced list initializers.  This
    means that two different structs that are initialized using the
    same braced list initializer may not be byte wise identical.
    Although not required in the C++ standard, the xlc compiler as
    well as several other C++ vendors already do this.
    
    Users who initialize structures with braced list initializers
    are affected.
    

Problem conclusion

  • Implemented -qxflag=zerofillpadbytes, which will zero fill pad
    bytes for auto variables that are POD structs.
    

Temporary fix

Comments

APAR Information

  • APAR number

    IZ32374

  • Reported component name

    XLC C++ AIX

  • Reported component ID

    5724S7100

  • Reported release

    900

  • Status

    CLOSED PER

  • PE

    NoPE

  • HIPER

    NoHIPER

  • Special Attention

    NoSpecatt

  • Submitted date

    2008-09-15

  • Closed date

    2008-09-15

  • Last modified date

    2008-09-17

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

    IZ25953

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

Fix information

  • Fixed component name

    XLC C++ AIX

  • Fixed component ID

    5724S7100

Applicable component levels

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

Document Information

Modified date:
03 October 2021