IBM Support

PH40308: INCORRECT STRUCT ARRAY FUNCTION PARAMETER WHEN ACCESSED VIA __PTR32 POINTER

A fix is available

Subscribe

You can track all active APARs for this component.

 

APAR status

  • Closed as program error.

Error description

  • When compiling in 64-bit mode, the function parameter list code
    generation for a pointer parameter using a __ptr32 qualification
    that accesses an array member in a struct may be calculated
    incorrectly.
    
    
    
       === TEST CASE ===
    
    int func(int*x, int z);
    
    struct a {
      int z;
      int y;
      int x[10];
    };
    
    int main() {
      struct a *__ptr32 test = 0;
      int z = func(test->x, sizeof(&(test->x[0])) + sizeof(test));
      return z;
    }
    
    
    Compile:
    xlc -S -Wc,"METAL,NOSE,SSCOMM,LP64,OPTIMIZE(3),
                           SEARCH(/usr/include/metal/)" test.c
    
    
    Incorrect:
    *   struct a *__ptr32 test = 0;         000010
             LGHI  14,0                     000010
    *   int z = func(test->x, ...           000011
    
    Correct:
    *   struct a *__ptr32 test = 0;         000010
    *   int z = func(test->x, ...           000011
             LGHI  14,8                     000011
    

Local fix

  • Specify a pointer type instead of the array type in the struct.
    

Problem summary

  • ****************************************************************
    * USERS AFFECTED: Uses accessing array members in structs      *
    *                 using alternate amode pointers to the        *
    *                 structure                                    *
    ****************************************************************
    * PROBLEM DESCRIPTION: Access to array struct members via a    *
    *                      ptr32 qualified pointer in 64-bit mode  *
    *                      may give incorrect offsets into the     *
    *                      structure.                              *
    ****************************************************************
    * RECOMMENDATION: Provide a cast.                              *
    ****************************************************************
    N/A
    

Problem conclusion

  • Fix this specialized point optimization/code gen.
    

Temporary fix

Comments

APAR Information

  • APAR number

    PH40308

  • Reported component name

    C/C++ FOR MVS

  • Reported component ID

    56551210A

  • Reported release

    7B0

  • Status

    CLOSED PER

  • PE

    NoPE

  • HIPER

    NoHIPER

  • Special Attention

    NoSpecatt / Xsystem

  • Submitted date

    2021-09-01

  • Closed date

    2021-09-08

  • Last modified date

    2021-10-01

  • APAR is sysrouted FROM one or more of the following:

    PH35278

  • APAR is sysrouted TO one or more of the following:

Modules/Macros

  • CCNECICS CCNECWI  CCNED230 CCNEDSCT CCNEDWRT CCNEFILT CCNEHIFC
    CCNEIPA3 CCNEIPAO CCNEMDEP CCNEOPTP CCNEP    CCNEPP   CCNETBY
    CCNMSGE  CCNMSGT  CCNQIPA
    

Fix information

  • Fixed component name

    C/C++ FOR MVS

  • Fixed component ID

    56551210A

Applicable component levels

  • R7B0 PSY UI77052

       UP21/09/29 P F109

Fix is available

  • Select the PTF appropriate for your component level. You will be required to sign in. Distribution on physical media is not available in all countries.

[{"Line of Business":{"code":"LOB08","label":"Cognitive Systems"},"Business Unit":{"code":"BU054","label":"Systems w\/TPS"},"Product":{"code":"SSTLTF","label":"z\/OS XL C\/C++"},"Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"7B0"}]

Document Information

Modified date:
02 October 2021