Fixes are available
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
LI78226
Reported component name
XL C/C++ FOR LI
Reported component ID
5725C7300
Reported release
D10
Status
CLOSED PER
PE
NoPE
HIPER
NoHIPER
Special Attention
NoSpecatt
Submitted date
2014-10-30
Closed date
2014-10-30
Last modified date
2014-10-30
APAR is sysrouted FROM one or more of the following:
APAR is sysrouted TO one or more of the following:
Fix information
Fixed component name
XL C/C++ FOR LI
Fixed component ID
5725C7300
Applicable component levels
RD10 PSN IV59939
UP06/09/13
[{"Business Unit":{"code":"BU058","label":"IBM Infrastructure w\/TPS"},"Product":{"code":"SSXVZZ","label":"XL C\/C++ for Linux"},"Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"13.1","Line of Business":{"code":"LOB57","label":"Power"}}]
Document Information
Modified date:
17 October 2021