IBM Support

PH40309: INCORRECT LOOP EXECUTION WHEN COMPILING WITH Z/OS COMPILER

A fix is available

Subscribe

You can track all active APARs for this component.

 

APAR status

  • Closed as program error.

Error description

  • When going through the assembler code of the while loop
    condition, the problem is that the assignment is performed
    twice, so the first element of t is skipped. If t has more
    elements, the 1st, 3rd, etc. elements are skipped.
    
    The following test case demonstrates this issue:
    
    ===== COMPILE COMMAND:
    c++ test.cpp
    
    
    ===== TESTCASE:
    $cat test.cpp
    #include <stdio.h>
    int main()
    {
        int i = 0;
        const int t[2] = { 1 };
        while (const int x = t[i++])
       {
            printf("In loop: i=%d\n", i);
       }
       printf("After loop: i=%d\n", i);
    
      return 0;
    }
    $
    
    
    ===== ACTUAL OUTPUT:
    $./a.out
    After loop: i=2
    $
    
    
    
    ===== EXPECTED OUTPUT:
    $ ./a.out
    In loop: i=1
    After loop: i=2
    $
    

Local fix

  • N/A
    

Problem summary

  • ****************************************************************
    * USERS AFFECTED: Users of the zosv2r4 C/C++ compiler          *
    ****************************************************************
    When going through the assembler code of the while loop
    condition, the problem is that the assignment is performed
    twice, so the first element of t is skipped. If it has more
    elements, the 1st, 3rd, etc. elements are skipped.
    

Problem conclusion

  • Apply service provided.
    

Temporary fix

Comments

APAR Information

  • APAR number

    PH40309

  • 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:

    PH18274

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

    UI77052

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