Fixes are available
APAR status
Closed as program error.
Error description
When inlining is enabled, a simple array memory address calculation is done incorrectly, giving an incorrect array element position. The issue is related to calculating an element position of an initialized array inside a struct using synatx: &array[0] + elem (GOOD) versus array + elem (BAD) Arrays outside of a struct work OK. === TEST CASE === #include <stdio.h> struct X { int a[7]; } x = { {1, 4, 9, 16, 25, 36, 49} }; int *safe(int (&array)[7], int elem) { return &array[0] + elem; } int *unsafe(int (&array)[7], int elem) { return array + elem; } int main() { printf("safe=%d, unsafe=%d\n", *safe(x.a,4), *unsafe(x.a,4)); return (safe(x.a,4) - unsafe(x.a,4)); } $ xlC -qinline test.cpp $ ./a.out safe=25, unsafe=4 $
Local fix
Do not use inlining.
Problem summary
USERS AFFECTED: Users with array pointer arithmetic using function inlining. PROBLEM DESCRIPTION: Problem with inlining function with array pointer arithmetic on return expression (e.x. 'return array + elem'). USERS AFFECTED: Users with array pointer arithmetic using function inlining.
Problem conclusion
The problem has been fixed.
Temporary fix
Comments
APAR Information
APAR number
IV91651
Reported component name
XL C/C++ FOR AI
Reported component ID
5725C7200
Reported release
D13
Status
CLOSED PER
PE
NoPE
HIPER
NoHIPER
Special Attention
NoSpecatt / Xsystem
Submitted date
2016-12-21
Closed date
2016-12-21
Last modified date
2016-12-21
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 AI
Fixed component ID
5725C7200
Applicable component levels
[{"Business Unit":{"code":"BU048","label":"IBM Software"},"Product":{"code":"SSGH3R","label":"XL C\/C++ for AIX"},"Component":"","ARM Category":[],"Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"D13","Edition":"","Line of Business":{"code":"LOB73","label":"Power TPS"}}]
Document Information
Modified date:
19 August 2024