Fixes are available
March 2009 Update for XL C/C++ Advanced Edition for Blue Gene/P, V9.0
August 2009 Update for XL C/C++ Advanced Edition for Blue Gene/P, V9.0
May 2010 Update for XL C/C++ Advanced Edition for Blue Gene/P, V9.0
December 2010 Update for XL C/C++ Advanced Edition for Blue Gene/P, V9.0
XL C/C++ Advanced Edition for Blue Gene/P Fix Pack 17 (October 2013 Update) for 9.0
April 2011 Update for XL C/C++ Advanced Edition for Blue Gene/P, V9.0
August 2011 Update for XL C/C++ Advanced Edition for Blue Gene/P, V9.0
April 2012 Update for XL C/C++ Advanced Edition for Blue Gene/P, V9.0
August 2012 Update for XL C/C++ Advanced Edition for Blue Gene/P, V9.0
APAR status
Closed as program error.
Error description
When using the 'offsetof()' in C++ on an array data member, with a typedef type, it will inproperly evaluate to 0. ================================================================ ===== TESTCASE: #include <stdio.h> #include <stddef.h> typedef unsigned char myarray[4]; typedef struct { myarray mymem; }myTDStruct; int main() { printf( ("offset of mymem[0]=%u\n"), offsetof (myTDStruct, mymem[0] )); printf( ("offset of mymem[1]=%u\n"), offsetof (myTDStruct, mymem[1] )); printf( ("offset of mymem[2]=%u\n"), offsetof (myTDStruct, mymem[2] )); printf( ("offset of mymem[3]=%u\n"), offsetof (myTDStruct, mymem[3] )); } ==== ACTUAL OUTPUT: offset of mymem[0]=0 offset of mymem[1]=0 offset of mymem[2]=0 offset of mymem[3]=0 ==== EXPECTED OUTPUT: offset of mymem[0]=0 offset of mymem[1]=1 offset of mymem[2]=2 offset of mymem[3]=3
Local fix
1) Compile with C 2) Remove the typedef ================================================================ ===== TESTCASE: #include <stdio.h> #include <stddef.h> typedef struct { unsigned char mymem[4]; }myUCStruct; int main() { printf( ("offset of mymem[0]=%u\n"), offsetof (myUCStruct, mymem[0] )); printf( ("offset of mymem[1]=%u\n"), offsetof (myUCStruct, mymem[1] )); printf( ("offset of mymem[2]=%u\n"), offsetof (myUCStruct, mymem[2] )); printf( ("offset of mymem[3]=%u\n"), offsetof (myUCStruct, mymem[3] )); }
Problem summary
offsetof on a array data member, with typedef type or an array type. The offset of expression is incorrectly evaluated to zero.
Problem conclusion
The compile time offset-of evaluation logic has been corrected to handle typedefs properly.
Temporary fix
Comments
APAR Information
APAR number
LI74270
Reported component name
XL C/C++ AE BG/
Reported component ID
5799HJE00
Reported release
900
Status
CLOSED PER
PE
NoPE
HIPER
NoHIPER
Special Attention
NoSpecatt
Submitted date
2009-03-20
Closed date
2009-03-20
Last modified date
2009-03-20
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++ AE BG/
Fixed component ID
5799HJE00
Applicable component levels
R900 PSN IZ35497
UP06/09/13
Document Information
Modified date:
16 October 2021