Fixes are available
XL C/C++ for AIX Fix Pack 19 (August 2014 PTF) for 11.1
XL C/C++ for AIX Fix Pack 20 (November 2014 PTF) for 11.1
XL C for AIX Fix Pack 21 (April 2015 PTF) for 11.1
XL C/C++ for AIX Fix Pack 21 (April 2015 PTF) for 11.1
XL C/C++ for AIX Fix Pack 22 (September 2015 PTF) for 11.1
XL C for AIX Fix Pack 23 (March 2016 PTF) for 11.1
XL C/C++ for AIX Fix Pack 23 (March 2016 PTF) for 11.1
XL C for AIX Fix Pack 24 (September 2016 PTF) for 11.1
XL C/C++ for AIX Fix Pack 24 (September 2016 PTF) for 11.1
XL C for AIX Fix Pack 19 (August 2014 PTF) for 11.1
XL C for AIX Fix Pack 20 (November 2014 PTF) for 11.1
XL C for AIX Fix Pack 22 (September 2015 PTF) for 11.1
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:
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
Document Information
Modified date:
19 August 2014