IBM Support

PH63278: OPTIMIZATION GENERATES INCORRECT ASSEMBLER INSTRUCTIONS FOR FUNCTION ARGUMENTS

A fix is available

Subscribe

You can track all active APARs for this component.

 

APAR status

  • Closed as program error.

Error description

  • When compiling the following testcase with optimization:
    **>cat structTypes.h**
    ```
    typedef struct twoFloatStruct {
                  float elem1;
                          float elem2;
    } twoFloatStruct;
    
    ```
    >
    **>cat test.c**
    ```
    #include <stdio.h>
    #include "structTypes.h"
    
    extern float assignElems(twoFloatStruct arg1, double arg2, int
    arg3);
    
    twoFloatStruct
    test(twoFloatStruct arg1, double arg2, int arg3, void *arg4) {
          twoFloatStruct retStruct;
          retStruct.elem1 = *(float *)arg4;
          retStruct.elem2 = assignElems(arg1, arg2, arg3);
          return retStruct;
    }
    ```
    >
    
    **>cat test2.c**
    ```
    #include <stdio.h>
    #include "structTypes.h"
    
    float
    assignElems(twoFloatStruct arg1, double arg2, int arg3) {
          return arg3 == 5000 ? arg1.elem1 + arg1.elem2 +
    (float)arg2 : -1.0F;
    }
    ```
    
    **>cat run.c**
    ```
    #include <stdio.h>
    #include "structTypes.h"
    
    extern twoFloatStruct test(twoFloatStruct arg1, double arg2, int
    
    arg3, void *arg4);
    
    twoFloatStruct
    testCaller(twoFloatStruct arg1, double arg2, int arg3, void
    *arg4)
    {         return test(arg1, arg2, arg3, arg4);
    }
    
    int main()
    {        twoFloatStruct inputStruct;
          twoFloatStruct retStruct;
          inputStruct.elem1 = 18.23F;
          inputStruct.elem2 = 23.18F;
          float floatInput = 5;
          retStruct = testCaller(inputStruct, 5.65, 5000,
    &floatInput);       printf("Return Elements: elem1: %f, elem2:
    %f, expected:
    5.0F and 47.06F\n", retStruct.elem1, retStruct.elem2);
          return 0;
    }
    ```
    **>**
    
    The assembler code generated from this testcase is incorrect and
    
    does not load arg3 onto the stack. arg1 is a complex-like type
    and therefore passed in FRP0 and FPR2. arg2 is passed in FPR4.
    These both arguments shadow GPR1/2/3, therefore arg3 must be
    passed on the stack.
    

Local fix

  • Turn off optimization or do not use 64-bit mode with
    optimization.
    

Problem summary

  • ****************************************************************
    * USERS AFFECTED: Users of V2R4 XL C/C++ at 64bit              *
    *                 OPT, passing complex float types (structs    *
    *                 containing                                   *
    *                 two 4 byte floating point type members) as   *
    *                 parameters in a function call.               *
    ****************************************************************
    * PROBLEM DESCRIPTION: If other parameters are passed          *
    *                      in the same function call as the        *
    *                      complex type,                           *
    *                      they may not be passed correctly to     *
    *                      the callee.                             *
    ****************************************************************
    * RECOMMENDATION: Install the PTF                              *
    ****************************************************************
    N/A
    

Problem conclusion

  • Install the PTF or use workaround
    

Temporary fix

Comments

APAR Information

  • APAR number

    PH63278

  • Reported component name

    C/C++ FOR MVS

  • Reported component ID

    56551210A

  • Reported release

    7C0

  • Status

    CLOSED PER

  • PE

    NoPE

  • HIPER

    NoHIPER

  • Special Attention

    NoSpecatt / Xsystem

  • Submitted date

    2024-09-17

  • Closed date

    2024-10-09

  • Last modified date

    2024-11-03

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

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

Modules/Macros

  • CCNECICS CCNECWI  CCNED240 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

  • R7C0 PSY UI98701

       UP24/10/30 P F410

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.

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

Document Information

Modified date:
03 November 2024