Fixes are available
XL C/C++ for AIX Fix Pack 11 (February 2015 PTF) for 12.1
XL C for AIX Fix Pack 12 (May 2015 PTF) for 12.1
XL C/C++ for AIX Fix Pack 12 (May 2015 PTF) for 12.1
XL C/C++ for AIX Fix Pack 13 (August 2015 Update) for 12.1
XL C/C++ for AIX Fix Pack 14 (December 2015 Update) for 12.1
XL C for AIX Fix Pack 15 (April 2016 Update) for 12.1
XL C/C++ for AIX Fix Pack 15 (April 2016 Update) for 12.1
XL C for AIX Fix Pack 16 (July 2016 Update) for 12.1
XL C/C++ for AIX Fix Pack 16 (July 2016 Update) for 12.1
XL C/C++ for AIX Fix Pack 17 (November 2016 Update) for 12.1
XL C for AIX Fix Pack 17 (November 2016 Update) for 12.1
XL C for AIX Fix Pack 18 (February 2017 Update) for 12.1
XL C/C++ for AIX Fix Pack 18 (February 2017 Update) for 12.1
XL C for AIX Fix Pack 19 (August 2017 Update) for 12.1
XL C/C++ for AIX Fix Pack 19 (August 2017 Update) for 12.1
XL C for AIX Fix Pack 20 (March 2018 Update) for 12.1
XL C/C++ for AIX Fix Pack 20 (March 2018 Update) for 12.1
XL C for AIX Fix Pack 9 (July 2014 PTF) for 12.1
XL C/C++ for AIX Fix Pack 9 (July 2014 PTF) for 12.1
XL C for AIX Fix Pack 10 (October 2014 PTF) for 12.1
XL C/C++ for AIX Fix Pack 10 (October 2014 PTF) for 12.1
XL C for AIX Fix Pack 11 (February 2015 PTF) for 12.1
XL C for AIX Fix Pack 13 (August 2015 Update) for 12.1
XL C for AIX Fix Pack 14 (December 2015 Update) for 12.1
XL C/C++ for AIX Fix Pack 21 (January 2019 Update) for 12.1
XL C for AIX Fix Pack 21 (January 2019 Update) for 12.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
IV59939
Reported component name
XL C/C++ AIX
Reported component ID
5724X1300
Reported release
C10
Status
CLOSED PER
PE
NoPE
HIPER
NoHIPER
Special Attention
NoSpecatt
Submitted date
2014-04-30
Closed date
2014-07-30
Last modified date
2014-07-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 FOR AIX
Fixed component ID
5725C7100
Applicable component levels
RC10 PSY
UP
Document Information
Modified date:
13 September 2021