IBM Support

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

Subscribe

You can track all active APARs for this component.

 

APAR status

  • Closed as fixed if next.

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

  • This issue has been fixed in the latest V2R4 November 2019 PTF.
    

Problem conclusion

Temporary fix

Comments

APAR Information

  • APAR number

    PH18051

  • Reported component name

    C/C++ FOR MVS

  • Reported component ID

    56551210A

  • Reported release

    7A0

  • Status

    CLOSED FIN

  • PE

    NoPE

  • HIPER

    NoHIPER

  • Special Attention

    NoSpecatt / Xsystem

  • Submitted date

    2019-10-15

  • Closed date

    2020-06-08

  • Last modified date

    2020-06-08

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

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

    PH18274

Fix information

Applicable component levels

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

Document Information

Modified date:
10 June 2020